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 |
贴段代码,16MS#include<iostream> #define SIZE 1010 using namespace std; int n,m,k,z,x,y; int t[SIZE]; bool v[SIZE],a[SIZE][SIZE]; bool find(int x) { for(int i=0;m-i>0;i++) { if(v[i]==false&&a[x][i]==true) { v[i]=true; if(t[i]==-1||find(t[i])) { t[i]=x; return true; } } } return false; } int findMatch(void) { int count=0; for(int i=0;n-i>0;i++) { memset(v,false,sizeof(v)); if(find(i)) count++; } return count; } int main() { while(scanf("%d",&n),n) { scanf("%d %d",&m,&k); memset(t,-1,sizeof(t)); memset(a,false,sizeof(a)); for(int i=0;k-i>0;i++) { scanf("%d %d %d",&z,&x,&y); if(x*y!=0) a[x][y]=true; } printf("%d\n",findMatch()); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator