标签:hdu tar for || open using detail mem target
模板题hdu2063
#include<bits/stdc++.h> using namespace std; const int N=550; int k,m,n,cnt; bool vis[N]; int ma[N],last[N]; struct orz{ int v,nex;}e[N*4]; void add(int x,int y) { cnt++; e[cnt].v=y; e[cnt].nex=last[x]; last[x]=cnt; } bool found(int x) { for (int i=last[x];i;i=e[i].nex) { if (!vis[e[i].v]) { int v=e[i].v; vis[v]=1; if (!ma[v]||found(ma[v])) { ma[v]=x; return 1; } } } return 0; } int main() { while (scanf("%d",&k)&&k) { scanf("%d%d",&m,&n); memset(ma,0,sizeof(ma)); memset(e,0,sizeof(e)); memset(last,0,sizeof(last)); cnt=0; int x,y; for (int i=1;i<=k;i++) { scanf("%d%d",&x,&y); add(x,y); } int ans=0; for (int i=1;i<=m;i++) { memset(vis,0,sizeof(vis)); if (found(i)) ans++; } printf("%d\n",ans); } }
标签:hdu tar for || open using detail mem target
原文地址:https://www.cnblogs.com/tetew/p/9021942.html