Courses
Time limit:20000/10000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 5040 Accepted Submission (s): 2430
Problem Descriptionconsider 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 was possible to form a committee of exactly P students that satisfies simultaneously t He conditions:
. Every student in the Committee represents a different course (a student can represent a course if he/she visits that cours E
. Each course have a representative in the Committee
Your program should read sets of the data from a text file. The first line of the input file contains the number of the data sets. Each data set was 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, each data set contains, positive integers separated by one blank:p (1 <= P <=)-The Numbe R of courses and N (1 <= n <=)-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 was a line this starts with an integer Count I (0 <= Count i <= N) representing the Numbe R of Students visiting course I. Next, after a blank, you'll find the Count I students, visiting the course, each of the consecutive separated by one blank. Students is numbered with the positive integers from 1 to N.
There is no blank lines between consecutive sets of data. Input data is correct.
The result of the program is in the standard output. For each input data set, prints on a, "YES" if it is possible to form a committee and "NO" otherwise . There should not being any leading blanks at the start of the line.
An example of program input and output:
Sample INPUT2 3 3 3 1 2 3 2 1 2 1 1 3 3 2 1 3 2 1 3 1 1
Sample Outputyes NO
Sourcesoutheastern Europe 2000
Recommendwe has carefully selected several similar problems for you:1068 2444 1150 1281 1054 to find the minimum, point coverage (maximum match value) is equal to the value of the collection element;
1#include <cstdio>2#include <cstring>3#include <iostream>4 using namespacestd;5 intmap[ -][ -], dis[ -], vis[ -];6 intn, u;7 BOOLSearch (inta) {8 for(inti =1; I <= u; i++){9 if(Map[a][i] &&!Vis[i]) {TenVis[i] =1; One if(!dis[i] | |Search (Dis[i])) { ADis[i] =A; - return true; - } the } - } - return false; - } + intMain () { - intT; +scanf"%d", &t); A while(t--){ atscanf"%d%d", &n, &u); -memset (Map,0,sizeof(map)); -memset (DIS,0,sizeof(DIS)); - for(inti =1; I <= N; i++){ - intA, B; -scanf"%d", &a); in for(intj =1; J <= A; J + +){ -scanf"%d", &b); toMAP[I][B] =1; + } - } the intCNT =0; * for(inti =1; I <= N; i++){ $memset (Vis,0,sizeof(Vis));Panax Notoginseng if(Search (i)) -cnt++; the } +printf (cnt==n?)"yes\n":"no\n"); A } the return 0; +}
Hangzhou Electric 1083--courses (two-part map matching)