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 1106. Two Teams

why i got WA???
Posted by bingo2002 29 Apr 2002 23:06
type
  info=record
         link:array[1..100]of integer;
         position:integer;
         count:integer;
       end;
label 99;
var
  n,i,j,temp,sum:integer;
  a:array[1..100]of info;
begin
  {assign(input,'input.txt');
  assign(output,'output.txt');
  rewrite(output);
  reset(input);  }
  readln(n);
  for i:=1 to n do
     begin
         read(temp);
         j:=0;
         while temp<>0 do
             begin
                 a[i].link[j]:=temp;
                 inc(j);
                 read(temp);
             end;
         dec(j);

         a[i].count:=j;
         if a[i].count=0 then
            goto 99;
         a[i].position:=0;
         readln;
     end;
   a[1].position:=1;
   sum:=1;
   for i:=1 to a[1].count do
      a[a[1].link[i]].position:=2;
   for i:=2 to n do
      begin
         if a[i].position=0 then
            begin
               a[i].position:=1;
               inc(sum);
               for j:=1 to a[i].count do
                  a[a[i].link[j]].position:=2;
            end;
      end;
   writeln(sum);
   writeln(output,sum);
   for i:=1 to n do
     if a[i].position=1 then
        begin
           write(i);
           write(' ');
        end;
   {close(input);
   close(output);}
99: writeln(0);
   readln;
end.