标签:register center printf cstring should change repr jobs round
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 15700 | Accepted: 6734 |
Description
Input
Output
Sample Input
5 5 10 0 1 1 1 1 2 2 1 3 3 1 4 4 2 1 5 2 2 6 2 3 7 2 4 8 3 3 9 4 3 0
Sample Output
3
Source
1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 6 inline void read(int &x) 7 { 8 x = 0;char ch = getchar(), c = ch; 9 while(ch < ‘0‘ || ch > ‘9‘) c = ch, ch = getchar(); 10 while(ch <= ‘9‘ && ch >= ‘0‘) x = x * 10 + ch - ‘0‘, ch = getchar(); 11 if(c == ‘-‘)x = -x; 12 } 13 14 const int MAXN = 100 + 10; 15 const int MAXK = 1000 + 10; 16 17 int g[MAXN][MAXN], lk[MAXN], b[MAXN], n, m, k, tmp1, tmp2; 18 19 int dfs(int u) 20 { 21 for(register int i = 1;i <= m;++ i) 22 { 23 if(!b[i] && g[u][i]) 24 { 25 b[i] = 1; 26 if(lk[i] == -1 || dfs(lk[i])) 27 { 28 lk[i] = u; 29 return 1; 30 } 31 } 32 } 33 return 0; 34 } 35 36 int xiongyali() 37 { 38 int ans = 0; 39 memset(lk, -1, sizeof(lk)); 40 for(register int i = 1;i <= n;++ i) 41 { 42 memset(b, 0, sizeof(b)); 43 ans += dfs(i); 44 } 45 return ans; 46 } 47 48 int main() 49 { 50 freopen("data.txt", "r", stdin); 51 while(scanf("%d %d %d", &n, &m, &k) != EOF && n) 52 { 53 memset(g, 0, sizeof(g)); 54 for(register int i = 1;i <= k;++ i) 55 { 56 read(tmp1), read(tmp1), read(tmp2); 57 if(tmp1 == 0 || tmp2 == 0) continue; 58 g[tmp1][tmp2] = 1; 59 } 60 printf("%d\n", xiongyali()); 61 } 62 return 0; 63 }
标签:register center printf cstring should change repr jobs round
原文地址:http://www.cnblogs.com/huibixiaoxing/p/7581810.html