Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

I don't know why I got WA....

Posted by Memtest at 2008-09-03 13:59:16 on Problem 3687 and last updated at 2008-09-03 14:00:05
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator