|
|
back to boardwhy WA Posted by vlad 16 Jun 2005 17:05 { My program task 7 2 3 0 3 1 0 1 2 4 5 0 3 0 3 0 7 0 6 0 answer 4 1 3 5 7 it is not the same as standart answer but it is also right } {$APPTYPE CONSOLE} var fr:array[1..100,0..99] of byte; A,B,mem:set of byte; n,i,j,kol:integer; group:char; label bed; procedure getfriend(n:integer); var i:integer; begin if (n in mem) and (not (n in a)) and (not (n in b)) then begin mem:=mem-[n]; if group='A' then begin inc(kol); a:=a+[n]; group:='B' end else begin b:=b+[n]; group:='A'; end; for i:=1 to fr[n,0] do getfriend(fr[n,i]); end end; begin { assign(Input,'input.txt'); assign(Output,'output.txt'); reset(Input); rewrite(Output); } group:='A'; readln(n); for I:=1 to n do begin j:=0; while not eoln do begin inc(j); read(fr[i,j]); end; if j=1 then begin writeln(0); goto bed; end; readln; fr[i,0]:=j-1; end; mem:=[1..n]; for i:=1 to n do getfriend(i); writeln(kol); for i:=1 to n do if i in A then write(I,' '); writeln; bed: { close(Input); close(Output);} end. see+++++++++++++ The 5 he has the friend 3, and with him in one command. In an opposite command the 5 does not have friends. Your answer false!!! |
|
|