标签:des style blog color java os io strong
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 10714 Accepted Submission(s): 4721
1 #include<string> 2 #include<cstdio> 3 #include<iostream> 4 #include<vector> 5 #include<queue> 6 #include<stack> 7 #include<algorithm> 8 #include<cstring> 9 #include<stdlib.h> 10 #include<string> 11 #include<cmath> 12 using namespace std; 13 #define pb push_back 14 int k,n,m; 15 int girl[510],vit[510]; 16 vector<int >ko[510]; 17 int Find(int pos){ 18 for(int i=0;i<ko[pos].size();i++){ 19 int to=ko[pos][i]; 20 if(!vit[to]){ 21 vit[to]=1; 22 if(girl[to]==-1||Find(girl[to])){ 23 girl[to]=pos; 24 return 1; 25 } 26 } 27 } 28 return 0; 29 } 30 void solve(){ 31 int cnt=0; 32 for(int i=1;i<=n;i++){ 33 memset(vit,0,sizeof(vit)); 34 if(Find(i)) cnt++; 35 } 36 cout<<cnt<<endl; 37 } 38 int main(){ 39 while(cin>>k,k){ 40 cin>>n>>m; 41 memset(girl,-1,sizeof(girl)); 42 for(int i=1;i<=n;i++) 43 ko[i].clear(); 44 for(int i=1;i<=k;i++){ 45 int a,b;scanf("%d%d",&a,&b); 46 ko[a].pb(b); 47 } 48 solve(); 49 } 50 }
标签:des style blog color java os io strong
原文地址:http://www.cnblogs.com/ainixu1314/p/3901801.html