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 |
我真是醉了,,就是不对,贴代码#include <iostream> #include <cstdio> #include <cstring> using namespace std; bool link[305][500],used[3000],girl[3000]; int n; bool find(int x) { for(int i=1;i<=n;i++) { if(link[x][i]&&used[i]==0) { used[i]=1; if(girl[i]==0||find(girl[i])) { girl[i]=x; return true; } } } return false; } int main() { int t,p,num,temp; cin >> t; while(t--) { scanf("%d%d",&p,&n); memset(link,0,sizeof(link)); memset(girl,0,sizeof(girl)); for(int i=1;i<=p;i++) { scanf("%d",&num); for(int j=1;j<=num;j++) { scanf("%d",&temp); link[i][temp]=1; } } int k; for(k=1;k<=p;k++) { memset(used,0,sizeof(used)); if(!find(k)) break; } if(k>p) cout << "YES" << endl; else cout << "NO" << 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