Make the Team

  • 比赛主页
  • 我的提交

时间限制:C/C++ 5秒,其他语言10秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld

题目描述

You are eager to make the programming team. You have decided that if you watch several videos,
you will increase your chances of making the team. Each video you want to watch is one hour
long, and each video plays at specific times. Naturally, you want to get through all the videos as
fast as possible, to leave more time to practice!
For example, if you want to watch two videos and the first one is available at the time intervals
[1,2), [4,5), [8,9) and [12,13), and the second video is available at the time intervals [4,5), [7,8),
and [11,12), then the earliest time at which you can complete the two videos is time 5. You can
accomplish this by watching the first video in the time interval [1,2) and the second one at the time
interval [4,5). Note that all videos play for precisely the length of one time interval, and one can
watch back to back videos. Thus, if one video plays at the interval [x, x+1) and another video

plays at the interval [x+1, x+2), where x is a positive integer, both can be watched, back to back.

Given a list of times that each video you want to watch is available, determine the earliest time at
which you can complete watching all of the videos. Note that the videos can be watched in any
order as long as the time intervals allow.

输入描述:

The first input line contains a single integer,n(1 ≤n≤ 200), indicating the number of videos you
would like to watch. Each of the nextninput lines describes a video you want to watch. Theith
of these input lines starts with an integer,ti(1 ≤ti≤ 30), representing the number of times videoi
is available to watch. This is followed bytispace separated values indicating the starting time
videoiis available to watch. The list of times for each video will be a strictly increasing list of
positive integers, with a maximum value of 1000. It is guaranteed that there will be at least one
arrangement that allows you to watch all of the videos.

输出描述:

Print the earliest time at which you can complete watching all of the videos.

示例1

输入

复制

3
2 4 6
3 4 9 11
1 4

输出

复制

10

示例2

输入

复制

4
2 3 11
3 2 9 11
2 2 3
2 3 9

输出

复制

12
#include<iostream>
#include<vector>using namespace std;
const int maxn=10010;
int vis[maxn];
int M[maxn];
vector<int> f[maxn];
int n,m;
int x;
int dfs(int x){for(int i=0;i<f[x].size();i++){if(!vis[f[x][i]]){vis[f[x][i]]=1;if(!M[f[x][i]]||dfs(M[f[x][i]])){M[f[x][i]]=x;return 1;}}}return 0;
}
int main(){cin>>n;for(int i=1;i<=n;i++){cin>>m;for(int j=1;j<=m;j++){cin>>x;f[x+1].push_back(i);}}int res=0;for(int i=1;i<=1001;i++){memset(vis, 0, sizeof(vis));if(dfs(i)) {res=i;}}cout<<res;
}

Make the Team(匈牙利算法)相关推荐

  1. 二分图匹配匈牙利算法DFS实现

    1 /*==================================================*\ 2 | 二分图匹配(匈牙利算法DFS 实现) 3 | INIT: g[][]邻接矩阵; ...

  2. 解题报告:luogu P2423 [HEOI2012]朋友圈【最大团转最大点独立集(匈牙利算法+时间戳优化)】

    图的最大团:"任意两点之间都有一条边相连"的子图被称为无向图的团,点数最多的团为图的最大团 朋友圈中任意两个点之间都有关系,既是图中的团. 答案就是图中的最大团. 我们如果把B国的 ...

  3. 二分图最大匹配(匈牙利算法) POJ 3020 Antenna Placement

    题目传送门 1 /* 2 题意:*的点占据后能顺带占据四个方向的一个*,问最少要占据多少个 3 匈牙利算法:按坐标奇偶性把*分为两个集合,那么除了匹配的其中一方是顺带占据外,其他都要占据 4 */ 5 ...

  4. 二分图匹配的匈牙利算法

    匈牙利算法,很绕,其实写起来也就一点点长度.. bool find(int a){int i,j;for(i=head[a];i;i=next[i]){j=to[i];//获得相邻的点if(!unab ...

  5. 二分图-匈牙利算法模板

    二分图就不赘述了,我在知识资料整理有相关资料. .最大匹配  .最小路径覆盖  .最小点覆盖  .最大独立集 最大匹配:二分图中边集最大的那个匹配 最小路径(边)覆盖:用尽量小的不想交简单路径覆盖有向 ...

  6. 二分图的最大匹配—匈牙利算法

    [基本概念]: 二分图: 二分图又称作二部图,是图论中的一种特殊模型. 设G=(V,E)是一个无向图,如果顶点V可分割为两个互不相交的子集(A,B),并且图中的每条边(i,j)所关联的两个顶点i和j分 ...

  7. BZOJ 1433 Luogu P2055 [ZJOI2009]假期的宿舍 匈牙利算法

    刚学了匈牙利正好练练手(我不会说一开始我写错了)(怕不是寒假就讲了可是我不会) 把人看做左部点,床看作右部点 建图:(!!在校相当于有床,不在校相当于没有床 但是要来学校) 1.在校的 不走的人 自己 ...

  8. 匈牙利算法学习笔记_Python代码

    学习华为上机测试题,遇见了下面题,很有意思,核心是匈牙利算法问题. 特此学习记录.资料均参考自网络. 匈牙利算法目的:找出两边最大的匹配的数量. 参考资料: https://blog.csdn.net ...

  9. 二分图的最大匹配(匈牙利算法)HDU1083

    二分图: 二分图又称作二部图,是图论中的一种特殊模型. 设G=(V,E)是一个无向图,如果顶点V可分割为两个互不相交的子集(A,B),并且图中的每条边(i,j)所关联的两个顶点i和j分别属于这两个不同 ...

  10. 用匈牙利算法求二分图的最大匹配

    转载大神的!! 什么是二分图,什么是二分图的最大匹配,这些定义我就不讲了,网上随便都找得到.二分图的最大匹配有两种求法,第一种是最大流(我在此假设读者已有网络流的知识):第二种就是我现在要讲的匈牙利算 ...

最新文章

  1. 拿下中科大的计算机课程全靠它了!
  2. 另一种同步软件Unison的使用方法
  3. android是32-bit系统还是64-bit系统
  4. mysql数据库中_截取数据_mysql数据库的字符串截取方法
  5. java获取s3对象url_java-如何通过SDK设置S3对象的内容类型?
  6. html仿京东快速购物导航,jQuery仿京东楼层滑动侧边栏高亮(原创)
  7. 中兴通讯携手ACCYOURATE发布“YouCare”5G智慧T恤
  8. [Audio processing] Harmonic change detection function (HCDF)
  9. gradle指令linux守护,gradle之gradlew最全指令攻略
  10. 40. 若一个类是函数子,则应该使它可配接
  11. python_四元数q转旋转矩阵R(已验证)
  12. 华为的手册和官网视频,学习网络基础
  13. 怎样从excel随机抽取多行
  14. axios请求跨域前端解决_10、axios请求以及跨域问题,前端解决方法。11、后端-nginx解决方法...
  15. 台式计算机连不上网,为什么台式电脑连不上wifi
  16. 某程序员动了公司祖传代码屎山,半年没改完,惭愧后交辞职报告
  17. Go学习笔记_环境搭建
  18. HTML怎么设置自动滚动的图片,转:HTML中让图片滚动的marquee标签的使用方法
  19. 简单的jq实现树形菜单
  20. Direct3d 设备丢失 (device lost)

热门文章

  1. 手机如何将PDF文件拆分?分享两种手机拆分文件方法
  2. U-GAT-IT 论文翻译
  3. BitTorrent
  4. 解决Namecheap域名转入确认邮件重发及邮件收不到
  5. 9.23 深度学习微调
  6. 星号密码查看器原理完全揭秘
  7. [exgcd] Jzoj P5855 吃蛋糕
  8. 买水货必看!你必须知道的10件事情
  9. 强者的系统:高观点下的人生
  10. dubbo源码分析23 -- provider 接收与发送原理