HUD——1083 Courses
HUD——1083 Courses
Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7699 Accepted Submission(s):
3781
student visits zero, one or more than one courses. Your task is to determine
whether it is possible to form a committee of exactly P students that satisfies
simultaneously the conditions:
. every student in the committee
represents a different course (a student can represent a course if he/she visits
that course)
. each course has a representative in the
committee
Your program should read sets of data from a text file. The
first line of the input file contains the number of the data sets. Each data set
is presented in the following format:
P N
Count1 Student1 1 Student1 2
... Student1 Count1
Count2 Student2 1 Student2 2 ... Student2
Count2
......
CountP StudentP 1 StudentP 2 ... StudentP CountP
The
first line in each data set contains two positive integers separated by one
blank: P (1 <= P <= 100) - the number of courses and N (1 <= N <=
300) - the number of students. The next P lines describe in sequence of the
courses . from course 1 to course P, each line describing a course. The
description of course i is a line that starts with an integer Count i (0 <=
Count i <= N) representing the number of students visiting course i. Next,
after a blank, you'll find the Count i students, visiting the course, each two
consecutive separated by one blank. Students are numbered with the positive
integers from 1 to N.
There are no blank lines between consecutive sets
of data. Input data are correct.
The result of the program is on the
standard output. For each input data set the program prints on a single line
"YES" if it is possible to form a committee and "NO" otherwise. There should not
be any leading blanks at the start of the line.
An example of program
input and output:
#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> #define N 501 using namespace std; bool vis[N]; int n,m,x,y,T,t,ans,pre[N],map[N][N]; int read() { ,f=;char ch=getchar(); ; ch=getchar();} +ch-'; ch=getchar();} return x*f; } int find(int x) { ;i<=n;i++) { if(!vis[i]&&map[x][i]) { vis[i]=true; ||find(pre[i])) { pre[i]=x; ; } } } ; } int main() { T=read(); while(T--) { ans=; memset(map,,sizeof(map)); m=read(),n=read(); ;i<=m;i++) { t=read(); while(t--) {x=read();map[i][x]=;} } if(n<m) printf("NO\n"); else { memset(pre,-,sizeof(pre)); ;i<=m;i++) { memset(vis,,sizeof(vis)); if(find(i)) ans++; } // printf("%d\n",ans); if(ans==m) printf("YES\n"); else printf("NO\n"); } } ; }
HUD——1083 Courses的更多相关文章
- HDU 1083 Courses 【二分图完备匹配】
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1083 Courses Time Limit: 20000/10000 MS (Java/Others) ...
- HDU 1083 - Courses - [匈牙利算法模板题]
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1083 Time Limit: 20000/10000 MS (Java/Others) M ...
- HDOJ 1083 Courses
Hopcroft-Karp算法模板 Courses Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (J ...
- hdoj 1083 Courses【匈牙利算法】
Courses Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total S ...
- hdu - 1083 - Courses
题意:有P门课程,N个学生,每门课程有一些学生选读,每个学生选读一些课程,问能否选出P个学生组成一个委员会,使得每个学生代言一门课程(他必需选读其代言的课程),每门课程都被一个学生代言(1 <= ...
- HDU - 1083 Courses /POJ - 1469
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1083 http://poj.org/problem?id=1469 题意:给你P个课程,并且给出每个课 ...
- HDU 1083 Courses(二分图匹配模板)
http://acm.hdu.edu.cn/showproblem.php?pid=1083 题意:有p门课和n个学生,每个学生都选了若干门课,每门课都要找一个同学来表演,且一个同学只能表演一门课,判 ...
- hdu 1083 Courses (最大匹配)
CoursesTime Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- HDU 1083 Courses(最大匹配模版题)
题目大意: 一共有N个学生跟P门课程,一个学生可以任意选一 门或多门课,问是否达成: 1.每个学生选的都是不同的课(即不能有两个学生选同一门课) 2.每门课都有一个代表(即P门课都被成功选过 ...
随机推荐
- String.format()【示例详解】
String.format()[示例详解] 整理者:Vashon 前言: String.format 作为文本处理工具,为我们提供强大而丰富的字符串格式化功能,为了不止步于简单调用 String.fo ...
- mac下iterm2配置安装,通过expact实现保存账号,及通过跳板登陆配置
在参考了几款mac不错的ssh工具外,最终选择使用iterm2.本来打算用FinalShell,安装后发现其icon在访达中根本不现实,而且每次访问还需要输入管理员账号密码,强迫症根本受不了... 官 ...
- MyEclipse 2015 安装到配置一站式备忘
目录 h1 2121 h1 2121
- CentOS 7下安装配置proftpd搭建ftp服务器
proftpd全称:Professional FTP daemon,是针对Wu-FTP的弱项而开发的,除了改进的安全性,还具备许多Wu-FTP没有的特点,能以Stand-alone.xinetd模式运 ...
- 光线步进——RayMarching入门
入门实现 先用RayMarching描绘一个球体,最后在进行光照计算参考:https://www.shadertoy.com/view/llt3R4 模拟摄像机射线float3 rayDirectio ...
- Python3中的输入输出
input()函数 我们可以通过Python3解释器查看Python3中input()的含义: >>> type(input) <class 'builtin_function ...
- 搜索 || BFS || POJ 2157 Maze
走迷宫拿宝藏,拿到所有对应的钥匙才能开门 *解法:从起点bfs,遇到门时先放入队列中,取出的时候看钥匙够不够决定开不开门,如果不够就把它再放回队列继续往下走,当队列里只有几个门循环的时候就可以退出,所 ...
- Microsoft Windows Server
Microsoft Windows Server Microsoft Windows Microsoft Windows 是微软推出的个人版操作系统: Microsoft Windows Server ...
- 微信公众号:theTree20181123
哈哈哈哈~我开通了一个微信公众号,以后的文章会发在公众号内啦~走过路过的小伙伴们过来围观一下呀~~ 主要是分为三个模块:视觉SLAM,ACM,变美树洞 这里面写下来的文章都是我再读研阶段的所学所想当然 ...
- 微信小程序入口场景的问题整理与相关解决方案
前言 最近一段时间都在做小程序. 虽然是第二次开发小程序,但是上次做小程序已经是一年前的事了,所以最终还是被坑得死去活来. 这次是从零开始开发一个小程序,其实除了一些莫名其妙的兼容性问题,大多数坑点都 ...