|
|
вернуться в форумI got WA!Why?Who can help me?Thank you! Послано New CD 19 дек 2002 18:14 program ti; var can,n,i,j:longint; p:boolean; cc:array[1..2]of integer; t1,t2:array[1..100]of integer; a:array[1..100,1..100]of boolean; begin fillchar(a,sizeof(a),false); readln(n); for i:=1 to n do begin read(j); while j<>0 do begin a[i,j]:=true; read(j); end; readln; end; fillchar(t1,sizeof(t1),0); fillchar(t2,sizeof(t2),0); t1[1]:=1; cc[1]:=1; cc[2]:=0; can:=0; for i:=2 to n do begin p:=true; for j:=1 to cc[1] do if not((a[i,t1[j]])and(a[t1[j],i])) then begin p:=false; break; end; if p then begin cc[1]:=cc[1]+1; t1[cc[1]]:=i; end else begin p:=true; for j:=1 to cc[2] do if not((a[i,t2[j]])and(a[t2 [j],i])) then begin p:=false; break; end; if p then begin cc[2]:=cc[2]+1; t2[cc[2]]:=i; end else begin can:=1; break; end; end; end; if (can=1) then begin write('No solution'); halt; end; can:=cc[1]; if cc[1]-cc[2]>1 then begin for i:=1 to cc[1] do begin p:=true; for j:=1 to cc[2] do if not((a[t1[i],t2[j]])and(a[t2 [j],t1[i]])) then begin p:=false; break; end; if p then begin cc[2]:=cc[2]+1; t2[cc[2]]:=t1[i]; t1[i]:=0; can:=can-1; if can-cc[2]<=1 then break; end; end; end; write(can); for i:=1 to cc[1] do if t1[i]<>0 then write(' ',t1[i]); writeln; write(cc[2]); for i:=1 to cc[2] do write(' ',t2[i]); end. |
|
|