刻錄光盤
阿新 • • 發佈:2018-10-04
while 光盤 思路 ssi llc rewrite begin long color
題面:
思路:
代碼:
var map:array[0..201,0..201] of boolean; father:array[0..201] of longint; i,j,k,n,t:longint; begin assign(input,‘cdrom.in‘); reset(input); assign(output,‘cdrom.out‘); rewrite(output); fillchar(map,sizeof(map),false); read(n); for i:=1 to n do begin read(t); while t<>0do begin map[i,t]:=true; read(t); end; end; for k:=1 to n do for i:=1 to n do for j:=1 to n do if map[i,k] and map[k,j] then map[i,j]:=true; for i:=1 to n do father[i]:=i; for i:=1 to n do for j:=1 to n do if map[i,j] then father[j]:=father[i]; t:=0; for i:=1to n do if father[i]=i then inc(t); write(t); close(input);close(output); end.
刻錄光盤