|
|
вернуться в форумОбщий форумProblem 1080. Pls Help : WA1 I have WA1:(. Here is my program: #include <iostream> using namespace std; #define N 100 int a[101][101]; bool Nnew[101]; int vc[N]; int next=0; bool DFS_rec(int v, int next,int n) { vc[v]=(next+1)%2; Nnew[v]=false; for(int j = 1; j <= n; j++) if(a[v][j]&&Nnew[j]) { if(vc[j] == -1) {if(!DFS_rec(j, vc[v], n))return false;} else if(vc[j] != next)return false; return true; } } int main() { short n; cin>>n; int j=1; for(int i=1;i<=n;i++) { while(j!=0) { cin>>j; a[i][j]=1; a[j][i]=1; } j=1; } for(int j=1;j<=N;j++) { Nnew[j]=true; vc[j]=-1; } DFS_rec(1,1,n); for(int i=1;i<=n;i++) if(vc[i]==-1) { cout<<vc[i]; goto end; } if(DFS_rec(1,1,n)) { for(int i=1;i<=n;i++) cout<<vc[i]; } cout<<endl; end: return 0; } Edited by author 07.01.2007 15:17 |
|
|