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门课都被成功选过 ...
随机推荐
- 解决异常System.Runtime.Interopservices.COMException RequestLock问题
工具——导入导出设置,重置调试设置就可以了,这是调试文件的异常
- centos 更换yum源 (解决下载慢的问题)
先看有没有安装wget wget -V 如果没有执行 yum -y install wget 进行安装 然后进行配置的备份 mv /etc/yum.repos.d/CentO ...
- c语言 预处理的使用 宏展开下的#,##
1. #include 包含头文件 2.define 宏定义(可以理解为替换,不进行语法检查) 写法 #define 宏名 宏体 加括号 #define ABC (5+3) #define AB ...
- String系列之replaceAll方法替换.
直接使用String类的replaceall方法的第一个参数并不是简单的字符串,而是一个正则表达式.在正则表达式中,英文点号(.)表示任意字符,所以你原先的写法会把所有字符都替换成空白. 转义使用所以 ...
- vscode setting.json
setting.json { "sync.gist": "#github的码##", "sync.lastUpload": "20 ...
- axios 两种异步模式,代理模式 和 异步模式
axios 两种异步模式,代理模式 和 异步模式
- vc枚举本机端口信息API
常用的获取端口信息的函数: GetTcpTableGetExtendedTcpTableGetUdpTableGetExtendedUdpTable GetTcp6Table function Get ...
- java_日期和时间
1.System类中的currentTimeMillis:1970年1.1到现在的毫秒数 public class DateTest { public static void main(String[ ...
- 283. Move Zeroes@python
Given an array nums, write a function to move all 0's to the end of it while maintaining the relativ ...
- 洛谷 P2858 奶牛零食
https://www.luogu.org/problemnew/show/P2858 毫无疑问区间dp. ![区间dp入门] 我们定义dp[i][j]表示从i到j的最大收益,显然我们需要利用比较小的 ...