|
|
вернуться в форумHelp why I got wa in test 3? var f,num:array[1..10000]of longint; a:array[1..10000,1..3]of longint; w,i,n,j:longint; procedure print(a:longint); var i,w:longint; b:array[1..10000]of longint; begin w:=0; fillchar(b,sizeof(b),0); for i:=1 to n do if f[i]=a then begin inc(w); b[w]:=i; end; writeln(w); if w<>0 then begin for i:=1 to w-1 do write(b[i],' '); writeln(b[w]); end; end; begin assign(input,'a.in'); reset(input); assign(output,'a.out'); rewrite(output); readln(n); for i:=1 to n do begin read(num[i]); for j:=1 to num[i] do read(a[i,j]); end; fillchar(f,sizeof(f),0); for i:=1 to n do if f[i]=0 then begin w:=0; for j:=1 to num[i] do if f[a[i,j]]=0 then inc(w); if w>1 then f[i]:=1; end; for i:=1 to n do begin w:=0; for j:=1 to num[i] do if f[i]=f[a[i,j]] then inc(w); if w>1 then begin writeln('NO SOLUTION'); close(input); close(output); halt; end; end; w:=0; for i:=1 to n do w:=w+f[i]; if w>n/2 then print(0) else if w<n/2 then print(1) else print(f[1]); close(input); close(output); end. Edited by author 08.12.2008 17:26 |
|
|