标签:ret scan iostream mem int ios ems color find
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> using namespace std; int n,m,k,ans,cnt,head[1001],vis[1001],match[1001]; struct uio{ int next,to; }edge[1000001]; int add(int x,int y) { edge[++cnt].to=y; edge[cnt].next=head[x]; head[x]=cnt; } bool find(int x) { for(int i=head[x];i;i=edge[i].next) { int y=edge[i].to; if(!vis[y]) { vis[y]=1; if(!match[y]||find(match[y])) { match[y]=x; return true; } } } return false; } int main() { scanf("%d%d%d",&n,&m,&k); for(int i=1;i<=k;i++) { int u,v; scanf("%d%d",&u,&v); add(u,v); } for(int i=1;i<=n;i++) { memset(vis,0,sizeof(vis)); if(find(i)) ans++; } printf("%d",ans); return 0; }
标签:ret scan iostream mem int ios ems color find
原文地址:https://www.cnblogs.com/water-radish/p/9280590.html