标签:tin where ret mem center format gre ota ref
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 8579 | Accepted: 5129 |
Description
Input
Output
Sample Input
2 4 3 3 4 1 3 2 3 3 3 1 3 1 2 2 3
Sample Output
2 1
Source
1 #include <cstring> 2 #include <cstdio> 3 4 using namespace std; 5 6 int n,map[123][123],match[123]; 7 bool vis[123]; 8 9 bool find(int u) 10 { 11 for(int v=1;v<=n;v++) 12 if(map[u][v]&&!vis[v]) 13 { 14 vis[v]=1; 15 if(!match[v]||find(match[v])) 16 { 17 match[v]=u; 18 return true; 19 } 20 } 21 return false; 22 } 23 24 int AC() 25 { 26 int t;scanf("%d",&t); 27 for(int m,ans;t--;) 28 { 29 scanf("%d%d",&n,&m);ans=n; 30 for(int u,v;m--;map[u][v]=1) 31 scanf("%d%d",&u,&v); 32 for(int i=1;i<=n;i++) 33 { 34 memset(vis,0,sizeof(vis)); 35 if(find(i)) ans--; 36 } 37 printf("%d\n",ans); 38 memset(map,0,sizeof(map)); 39 memset(match,0,sizeof(match)); 40 } 41 return 0; 42 } 43 44 int I_want_AC=AC(); 45 int main(){;}
标签:tin where ret mem center format gre ota ref
原文地址:http://www.cnblogs.com/Shy-key/p/7424322.html