| ||||||||||
| 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 | |||||||||
why WA !! helptype
pointer=^rec;
rec=record
k:longint;
next:pointer;
end;
var
cover:array[1..200]of boolean;
link:array[1..200]of pointer;
ans,du:array[1..200]of longint;
n,m,t,k,i:longint;
procedure init;
var
i,a,b:longint;
p:pointer;
begin
readln(n,m);
for i:=1 to n do link[i]:=nil;
fillchar(du,sizeof(du),0);
for i:=1 to m do
begin
readln(a,b);
new(p);
p^.k:=a;
p^.next:=link[b];
link[b]:=p;
inc(du[a]);
end;
end;
procedure main;
var
i:longint;
bool:boolean;
p:pointer;
begin
k:=0;
fillchar(cover,sizeof(cover),false);
while bool do
begin
bool:=false;
for i:=n downto 1 do
if (du[i]=0)and(not cover[i]) then
begin
inc(k);
ans[i]:=k;
p:=link[i];
while p<>nil do
begin
dec(du[p^.k]);
p:=p^.next;
end;
cover[i]:=true;
bool:=true;
break;
end;
end;
end;
procedure outit;
var
i:longint;
begin
if k<n then writeln(-1) else
begin
for i:=1 to k do
begin
if i<>1 then write(' ');
write(n+1-ans[i]);
end;
writeln;
end;
end;
begin
readln(t);
for i:=1 to t do
begin
init;
main;
outit;
end;
end.
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator