Topic links
n classes, each lesson in a section of one weeks, for a maximum of a few lessons
Well, thought for a long while did not want to come out, finally looked at the puzzle is the two-figure maximum match, good weak
Map: Each lesson and time has an edge
1#include <iostream>2#include <cstdio>3#include <cmath>4#include <cstring>5#include <algorithm>6#include <vector>7 using namespacestd;8 Const intN = -+5;9 intVis[n], left[n];Tenvector<int>G[n]; One intN; A BOOLMachintu) - { - intSize =g[u].size (); the for(inti =0; i < Size; i++) - { - intv =G[u][i]; - if(!Vis[v]) + { -VIS[V] =1; + if(Left[v] = =-1||Mach (left[v])) A { atLEFT[V] =u; - return true; - } - } - } - return false; in } - intMain () to { + while(SCANF ("%d", &n)! =EOF) - { the intT, p, Q; * for(inti =0; I <= N; i++) $ g[i].clear ();Panax Notoginseng for(inti =1; I <= N; i++) - { thescanf"%d", &t); + for(intj =1; J <= T; J + +) A { thescanf"%d%d", &p, &q); +G[i].push_back (P * A+ q);//each section can be converted into an integer - } $ } $Memset (left,-1,sizeof(left)); - intAns =0; - for(inti =1; I <= N; i++) the { -memset (Vis,0,sizeof(Vis));Wuyi if(Mach (i)) theans++; - } Wuprintf"%d\n", ans); - } About return 0; $}
View Code
POJ2239 Selecting Courses (binary graph Max match)