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 |
why???In Reply To:没考虑模式0的情况WA了一次…… Posted by:wyc4662 at 2011-07-28 18:16:17 #include<iostream> using namespace std; bool map[1001][1001]; bool flag[1001]; int match[1001]; int n,k,m; bool Dfs(int i) { int j; for(j=0;j<m+n;j++) { if(flag[j]&&map[i][j]) { flag[j]=false; if(match[j]==-1||Dfs(match[j])) { match[j]=i; return true; } } } return false; } int main() { int a,b,i,c; int sum,you; while(cin>>n,n) { cin>>m>>k; memset(map,false,sizeof(map)); memset(match,-1,sizeof(match)); sum=0; for(i=0;i<k;i++) { cin>>a>>b>>c; if(b&&c) { map[a][b]=1; map[a][c+n+1]=1; } } for(i=0;i<k;i++) { memset(flag,true,sizeof(flag)); if(Dfs(i)) { sum++; } } cout<<k-sum<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator