|
|
back to boardWhy I have got C.E.? #include<iostream.h> int a[101][101]; int order[101],bool[101],use[101]; int n; void reader() { int i,j; cin>>n; for (i=1; i<=n; i++) { cin>>j; while (j!=0) { a[i][j]=1; a[i][0]++; cin>>j; } } } int check() { int i; for (i=1; i<=n; i++) if (use[i]==0) return(1); return(0); } void main() { reader(); int i,j,o; o=0; while (check()) { for (j=0; j<=n; j++) bool[j]=0; for (i=n; i>0; i--) { if ((a[i][0]==0)&&(bool[j]==0)&&(use[i]==0)) { o++; order[o]=i; for (j=1; j<=n; j++) if (a[j][i]==1) {a[j][i]=0; a[j][0]--; bool[j]=1;} use[i]=1; } } } for (i=o; i>1; i--) { cout<<order[i]<<' '; } cout<<order[1]<<endl; } |
|
|