"Hdoj 2063" roller Coaster
Binary graph maximum matching template question 1 female to n male Q match maximum logarithm
The code is as follows:
#include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <queue&
Gt
#define INF 0x3f3f3f3f using namespace std;
Vector <int> head[555];
BOOL vis[555];
int link[555],n,m;
BOOL can (int p) {int i,v;
for (i = 0; i < head[p].size (); ++i) {v = head[p][i];
if (!vis[v]) {Vis[v] = true;
if (link[v] = = 1 | | can (LINK[V])) {link[v] = p;
return 1;
}}} return 0;
} int main () {int k,u,v,i,cnt;
while (~SCANF ("%d", &k) && k) {memset (head,0,sizeof (head));
scanf ("%d%d", &m,&n);
while (k--) {scanf ("%d%d", &u,&v);
Head[u].push_back (v);
} cnt = 0;
memset (link,-1,sizeof (link));
for (i = 1; I <= m; ++i) {memset (vis,0,sizeof (VIS));
if (Can (i)) cnt++; } printf ("%d\n", CNT);
} return 0;
}