Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哪位高手帮忙看一下,为什么总是WR,查不出错了//WR #include<iostream.h> #include<string.h> int con[500][500]; int last[500]; int match[500]; int n,m; int Dfs(int); int main() { int i,ans,x,y; cin >> n >> m; while (n+m) { memset(con,0,sizeof(con)); memset(match,-1,sizeof(match)); for(i=0;i<m;i++) { cin >> x >> y; con[x-1][y-1]=1; } ans=0; for(i=0;i<n;i++) { memset(last,0,sizeof(last)); if (Dfs(i)) ans++; } cout << n-ans << endl; cin >> n >> m; } return 0; } int Dfs(int p) { int i,t; for(i=0;i<n;i++) if(con[p][i] && !last[i]) { last[i]=1; t=match[i]; match[i]=p; if(t==-1 || Dfs(t)) return 1; match[i]=t; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator