ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1069. Prufer Code

Help me pls.
Posted by VALERO 29 Jan 2005 19:46
why i have wa 1?
there is my program

var A, B, C : array[1..7500] of integer;
    n, i, o : integer;

begin
while not eof do
begin Inc(n); read(A[i]);Inc(B[A[i]]); end;
n:=n+1;
for i:=1 to n do
begin
 o:=1;
 while B[o]<>0 do Inc(o);
 C[i]:=o;B[o]:=1;
 dec(B[A[i]]);
end;
for i:=1 to n do
begin
write(i,':');
for o:=1 to n do
if (A[o]=i) and (C[o]>0) then write(' ',C[o]) else
if (C[o]=i) and (A[o]>0) then write(' ',A[o]);
writeln;
end;

end.

Edited by author 29.01.2005 19:50