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 |
为什么会WA呢 那位大牛帮忙看看!!#include<iostream> #include<cstring> using namespace std; int m, P, N, count, stu, ans = 0; int result[101]; int used[101]; int data[301][101]; bool find( int v ) { for( int j = 1; j <= P; ++j ) { if( data[v][j] && !used[j] ) { used[j] = 1; if( result[j] == 0 || find(result[j]) ) { result[j] = v; return true; } } } return false; } void init() { memset(data,0,sizeof(data)); memset(result,0,sizeof(result)); scanf("%d %d",&P,&N); if( P > N ) { printf("NO\n"); return; } for( int i = 1; i <= P; i++ ) { scanf("%d",&count); for( int j = 1; j <= count; ++j ) { scanf("%d",&stu); data[i][stu] = 1; } } ans = 0; for( int j = 1; j <= N; ++j ) { memset(used,0,sizeof(used)); if( find(j) ) ans++; } if( ans == P ) printf("YES\n"); else printf("NO\n"); return ; } int main() { scanf("%d",&m); while( m-- ) init(); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator