Girls and boys
Time Limit: 20000/10000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 5528 accepted submission (s): 2466 problem descriptionthe second year of the university somebody started a study on the romantic relations between the students. the relation "romantically involved" is defined between one girl and one boy. for the study reasons it is necessary to find
Out of the maximum set satisfying the condition: there are no two students in the set who have been "romantically involved". The result of the program is the number of students in such a set.
The input contains several data sets in text format. Each data set represents one set of subjects of the study, with the following description:
The number of students
The description of each student, in the following format
Student_identifier :( number_of_romantic_relations) student_identifier1 student_identifier2 student_identifier3...
Or
Student_identifier :( 0)
The student_identifier is an integer number between 0 and n-1, for N subjects.
For each given data set, the program shocould write to standard output a line containing the result.
Sample Input
70: (3) 4 5 61: (2) 4 62: (0)3: (0)4: (2) 0 15: (1) 06: (2) 0 130: (2) 1 21: (1) 02: (1) 0
Sample output
52/* This probably means finding the largest set to associate any two persons in the set. Based on the maximum independent set = number of vertices-the maximum number of matching results, because the question does not show which are male and which are female, that is, there is no obvious bipartite graph, a person is split into two persons for maximum matching. Because one is split into two, the maximum number of matches should be calculated by dividing by 2. */# Include <cstdio> # include <cstring> # include <cmath> # include <algorithm> # define maxn 1005 using namespace STD; int n, m, ans; int G [maxn] [maxn], CX [maxn], CY [maxn], MK [maxn]; int path (int u) {int V; For (V = 0; v <n; V ++) {If (G [u] [v] &! MK [v]) {MK [v] = 1; if (! CY [v] | path (CY [v]) {cx [u] = V; CY [v] = u; // printf ("u: % d V: % d \ n ", u, v); return 1 ;}} return 0 ;}void March () {int I, j; ans = 0; memset (CX, 0, sizeof (CX); memset (CY, 0, sizeof (CY); for (I = 0; I <n; I ++) {If (! CX [I]) {memset (MK, 0, sizeof (MK); ans + = path (I) ;}} int main () {int I, j, t, temp, s; while (~ Scanf ("% d", & N) {memset (G, 0, sizeof (g); for (I = 1; I <= N; I ++) {scanf ("% d", & S); scanf ("% * C % d % * C", & M ); for (j = 1; j <= m; j ++) {scanf ("% d", & temp ); G [s] [temp] = G [temp] [s] = 1 ;}} March (); printf ("% d \ n ", n-ans/2);} return 0 ;}