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 1022. Genealogical Tree

Why WA? Please help me.
Posted by Yang Yi 20 Sep 2002 16:18
var
  a:array[0..101]of set of 0..101;
  b:array[0..101]of integer;
  c:array[0..101]of byte;
  n,i,j,k:integer;
begin
  fillchar(c,sizeof(c),0);
  readln(n);
  for i:=1to n do
  begin
    a[i]:=[];read(j);while j<>0do begin a[i]:=a[i]+[j];read(j)end
  end;
  i:=0;
  while i<n do
  begin
    for j:=n downto 1do
    if(c[j]=0)and(a[j]=[])then
    begin
      inc(i);b[i]:=j;c[j]:=1;
      for k:=1to n do
      a[k]:=a[k]-[j]
    end
  end;
  for i:=n downto 1do write(b[i],' ');writeln
end.
Re: Why WA? Please help me.
Posted by Yang Yi 22 Sep 2002 09:40
> var
>   a:array[0..101]of set of 0..101;
>   b:array[0..101]of integer;
>   c:array[0..101]of byte;
>   n,i,j,k:integer;
> begin
>   fillchar(c,sizeof(c),0);
>   readln(n);
>   for i:=1to n do
>   begin
>     a[i]:=[];read(j);while j<>0do begin a[i]:=a[i]+[j];read(j)end
>   end;
>   i:=0;
>   while i<n do
>   begin
>     for j:=n downto 1do
>     if(c[j]=0)and(a[j]=[])then
>     begin
>       inc(i);b[i]:=j;c[j]:=1;
>       for k:=1to n do
>       a[k]:=a[k]-[j]
>     end
>   end;
>   for i:=n downto 1do write(b[i],' ');writeln
> end.
Re: I've got AC.
Posted by Yang Yi 22 Sep 2002 09:41