标签:usaco for ext turn min desc single size get
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 22191 | Accepted: 12038 |
Description
Input
Output
Sample Input
3 4 1 1 1 3 2 2 3 2
Sample Output
2
Hint
Source
#include<cstdio> #include<cstring> using namespace std; int n,m,ans; bool v[501]; int a[501][501],match[501]; bool go(int u) { for(int i=1;i<=n;i++) if(a[u][i]&&!v[i]) { v[i]=true; if(!match[i]||go(match[i])) { match[i]=u; return 1; } } return 0; } int main() { scanf("%d%d",&n,&m); int x,y; for(int i=1;i<=m;i++) { scanf("%d%d",&x,&y); a[x][y]=true; } for(int i=1;i<=n;i++) { memset(v,0,sizeof(*v)*(n+1)); if(go(i)) ans++; } printf("%d",ans); }
标签:usaco for ext turn min desc single size get
原文地址:http://www.cnblogs.com/TheRoadToTheGold/p/6725010.html