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 1128. Partition into Groups

Why I got WA at test 3? Could you help me?
Posted by Tang RZ 29 Jul 2004 10:28
var
  flag:boolean;
  total,n,i,j,l,k:integer;
  b:array [1..10000] of boolean;
  data,a:array [1..10000] of integer;

begin
  read(n);
  k:=0;
  fillchar(data,sizeof(data),0);
  fillchar(b,sizeof(b),true);
  for i:=1 to n do
    begin
      read(l);
      total:=0;
      for j:=1 to l do
        begin
          read(a[j]);
          if b[a[j]] then inc(total);
        end;
      if total>1 then
        begin
          b[i]:=false;
          inc(k);
          data[k]:=i;
        end;
    end;
  if k<=n-k then
    begin
      writeln(k);
      for i:=1 to k do
        write(data[i],' ');
    end
    else
      begin
        writeln(n-k);
        for i:=1 to n do
          begin
            flag:=true;
            for j:=1 to k do
              if i=data[j] then flag:=false;
            if flag then write(i,' ');
          end;
      end;
  writeln;
end.