- Victoria的舞会2
- 2014-03-03 20:40:09 @
弱数据 Floyd
哥没用dfs哦
var n,sum,i,x,k,j:longint;bo:boolean;b:array[0..200,0..200]of boolean;
a:array[0..200]of boolean;
begin
readln(n);fillchar(b,sizeof(b),false);sum:=0;
fillchar(a,sizeof(a),true);
for i:=1 to n do
begin
read(x);
while(x<>0)do begin b[i,x]:=true;read(x);end;
end;
for k:=1 to n do
for i:=1 to n do
for j:=1 to n do
if i<>j then
b[i,j]:=b[i,j]or(b[i,k]and b[k,j]);
for i:=1 to n do
if a[i] then
begin
for j:=1 to n do
if(j<>i)and b[i,j]and b[j,i] then a[j]:=false;
inc(sum);a[i]:=false;
end;
writeln(sum);
end.
1 条评论
-
Balance LV 7 @ 2016-02-04 21:02:34
Floyed??为什么不用并查集+路径压缩?
- 1