| ||||||||||
| 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 | |||||||||
I don't know why I got WA....I use T-SORT.
#include <ios>
int T,N,M,in[201],seq[201];
bool w[201][201];
int main()
{
int i,j,a,b;
for (scanf("%d",&T);T--;){
scanf("%d%d",&N,&M);
for (i=1;i<=M;i++) scanf("%d%d",&a,&b), w[a][b] = 1, in[b]++;
for (i=1;i<=N;i++){
for (j=1;j<=N;j++) if (!in[j]) break;
if (j > N) break;
in[j] = -1;
seq[a=j] = i;
for (j=1;j<=N;j++) if (w[a][j]) in[j]--;
}
if (i <= N) printf("-1");
else for (i=1;i<=N;i++) printf("%d ",seq[i]);
printf("\n");
for (i=1;i<=N;in[i]=0,i++) for (j=1;j<=N;j++) w[i][j] = 0;
}
return 0;
}
Can anybody tell me?
p.s: I don't know chinese
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator