HDU 1083(图论,二分匹配)
来源:互联网 发布:网络用语2017最新 编辑:程序博客网 时间:2024/05/22 04:34
Courses
Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 733 Accepted Submission(s): 349
Problem Description
Consider a group of N students and P courses. Each 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:
. 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:
Sample Input
23 33 1 2 32 1 21 13 32 1 32 1 31 1
Sample Output
YESNO
- HDU 1083(图论,二分匹配)
- hdu-2444,hdu-1083 (二分匹配)
- HDU 1083 二分匹配
- hdu 1083 二分匹配
- HDU 1083 二分匹配
- HDU 1083 Courses (二分最大匹配)
- hdu 1083 Courses (二分图匹配)
- hdu 1083 Courses (简单二分匹配)
- hdu 1083 Courses(二分最大匹配)
- HDU 1083 Coures(二分图匹配)
- HDU 1083 Courses(二分图匹配)
- HDU 1068(图论,二分匹配)
- HDU 2063(图论,二分匹配)
- HDU 1083 二分匹配 Courses
- HDU 1083 二分匹配图
- HDU 1083 二分图匹配
- HDU-1083-Courses [二分匹配]
- hdu 3729(二分匹配)
- js鼠标事件大全
- 【转】C#索引器-索引器的定义
- pku 1002 487-3279
- 错误: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. 解决方案
- Web 领域那些阴魂不散的产品,技术与思想
- HDU 1083(图论,二分匹配)
- Java相对路径读取文件
- 页面中声明方式定义的用户控件与页面事件的执行顺序
- 帮帮忙
- Eclipse RCP 系统任务栏
- 最后期限摘要
- Altium Designer之模块复用——设备图表符与Snippets
- xml文件的序列化 和反序列化
- Spring简单的一个schema 介绍