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 |
g[100][300]; WAIn Reply To:-_- 为什么动态开辟数组 RE -_- Posted by:dreamseeker at 2007-01-16 14:34:13 #include"iostream" using namespace std; bool g[100][300]; int n,m; int mat[100],tmat[300]; int find(int i) { int v,j; for (j=0;j<m;j++) if (g[i][j]&&tmat[j]==0) { tmat[j]=1;v=mat[j]; mat[j]=i; if (v==-1||find(v)) return 1; mat[j]=v; } return 0; } int match() { int i,k=0; memset(mat,-1,sizeof(mat)); for (i=0;i<n;i++) { memset(tmat,0,sizeof(tmat)); k+=find(i); } return k; } int main() { int i,j,t,Case,p; cin>>Case; while(Case--) { cin>>n>>m; for (i=0;i<n;i++) for (j=0;j<m;j++) g[i][j]=false; for (i=0;i<n;i++) { scanf("%d",&t); while(t--) { scanf("%d",&p); g[i][p-1]=true; } } if(match()==n) printf("YES\n"); else printf("NO\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator