标签:mat map 整数 接下来 ssi scan 多少 main script
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 23984 Accepted Submission(s):
10453
#include <cstring> #include <cstdio> #define N 505 bool vis[N]; int ans,Map[N][N],match[N],k,m,n; int dfs(int x) { for(int i=1;i<=n;++i) { if(Map[x][i]&&!vis[i]) { vis[i]=1; if(!match[i]||dfs(match[i])) { match[i]=x; return 1; } } } return 0; } int main() { for(;scanf("%d",&k)&&k;) { scanf("%d%d",&m,&n); memset(Map,0,sizeof(Map)); memset(match,0,sizeof(match)); ans=0; for(int x,y;k--;) { scanf("%d%d",&x,&y); Map[x][y]=1; } for(int i=1;i<=m;++i) { memset(vis,0,sizeof(vis)); ans+=dfs(i); } printf("%d\n",ans); } return 0; }
标签:mat map 整数 接下来 ssi scan 多少 main script
原文地址:http://www.cnblogs.com/ruojisun/p/7435870.html