标签:
http://poj.org/problem?id=3041
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 17543 | Accepted: 9548 |
Description
Input
Output
Sample Input
3 4 1 1 1 3 2 2 3 2
Sample Output
2
Hint
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #define INF 0x3f3f3f3f #define N 510 int G[N][N], vis[N], used[N]; int n; bool Find(int u) { int i; for(i = 1 ; i <= n ; i++) { if(!vis[i] && G[u][i]) { vis[i] = 1; if(!used[i] || Find(used[i])) { used[i] = u; return true; } } } return false; } int main() { int a, b, k, i, ans; while(~scanf("%d%d", &n, &k)) { ans = 0; memset(G, 0, sizeof(G)); while(k--) { scanf("%d%d", &a, &b); G[a][b] = 1; } memset(used, 0, sizeof(used)); for(i = 1 ; i <= n ; i++) { memset(vis, 0, sizeof(vis)); if(Find(i)) ans++; } printf("%d\n", ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/qq2424260747/p/4713854.html