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

WA. HELP NEED.
Posted by I am david. Tabo. 10 Dec 2002 20:01
type
  info=record
     fri:array[1..101]of integer;
     no:integer;
     count:integer;
  end;
label endof, endla;
var
  n,sum,i,j:integer;
  node:array[1..100]of info;
  temp:integer;
begin
assign(input,'input.txt');
assign(output,'output.txt');
  readln(input,n);
  for i:=1 to n do
    begin
      read(input,temp);
      j:=1;
      while temp<>0 do
         begin
            node[i].fri[j]:=temp;
            inc(j);
            read(input,temp);
         end;
      dec(j);
      node[i].count:=j;
      node[i].no:=0;
      if j=0 then goto endof;
      readln;
    end;
  sum:=0;
  node[1].no:=1;
  inc(sum);
  for i:=1 to node[1].count do
     node[node[1].fri[i]].no:=2;
  for i:=2 to n do
    begin
    if node[i].no<>2 then
       begin
         node[i].no:=1;
         inc(sum);
         for j:=1 to node[i].count do
            node[node[i].fri[j]].no:=2;
       end;
    end;
    writeln(output,sum);
    for i:=1 to n do
     begin
      if node[i].no=1 then
        begin
         write(output,i);
         write(output,' ');
        end;
     end;
     goto endla;
endof: write(output,0);
endla:  { TODO -oUser -cConsole Main : Insert code here }
end.