标签:hdoj过山车
6 3 3 1 1 1 2 1 3 2 1 2 3 3 1 0
3
#include<cstdio> #include<cstdlib> #include<cstring> using namespace std; int partner[520][520]; int vis[520],p[520],N,M; int find(int k){ for(int i=1;i<=M;++i){ if(!vis[i]&&partner[k][i]){ vis[i]=1; if(p[i]==0||find(p[i])){ p[i]=k;return 1; } } } return 0; } int main() { int k,i,j,a,b; while(scanf("%d",&k),k){ memset(partner,0,sizeof(partner)); memset(p,0,sizeof(p)); scanf("%d%d",&N,&M); for(i=0;i<k;++i){ scanf("%d%d",&a,&b); partner[a][b]=1; } int ans=0; for(i=1;i<=N;++i){ memset(vis,0,sizeof(vis)); if(find(i))ans++; } printf("%d\n",ans); } return 0; }
标签:hdoj过山车
原文地址:http://blog.csdn.net/r1986799047/article/details/44497545