标签:des style blog color java os io strong
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 10776 Accepted Submission(s): 4748
1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <string> 5 #include <iomanip> 6 #include <algorithm> 7 #include <queue> 8 #include <vector> 9 #include <map> 10 using namespace std; 11 #define maxn 505 12 int mp[maxn][maxn], line[maxn]; 13 int vis[maxn]; 14 int K, M, N, ans; 15 bool find(int x){ 16 for(int i = 1; i <= N; i++){ 17 if(!vis[i] && mp[x][i] == 1){ 18 vis[i] = 1; 19 if(!line[i] || find(line[i])){ 20 line[i] = x; 21 return true; 22 } 23 } 24 } 25 return false; 26 } 27 void hungry(){ 28 ans = 0; 29 memset(line, 0, sizeof(line)); 30 for(int i = 1; i <= M; i++){ 31 memset(vis, 0, sizeof(vis)); 32 if(find(i)) ans++; 33 } 34 printf("%d\n", ans); 35 } 36 int main(){ 37 while(scanf("%d", &K) && K){ 38 scanf("%d%d", &M, &N); 39 memset(mp, 0, sizeof(mp)); 40 for(int i = 1; i <= K; i++){ 41 int a,b; 42 scanf("%d%d", &a, &b); 43 mp[a][b] = 1; 44 } 45 hungry(); 46 } 47 48 return 0; 49 }
hdu 2063 过山车(二分图匹配最大匹配数模板),布布扣,bubuko.com
标签:des style blog color java os io strong
原文地址:http://www.cnblogs.com/titicia/p/3905811.html