- Victoria的舞会2
- 2015-02-26 21:03:23 @
program p1022(input,output);
var a:array[1..200,1..200] of longint;
visit:array[1..200] of boolean;
n,i,ans,x,j:longint;
procedure dfs(n:longint);
var i:longint;
begin
visit[n]:=true;
for i:=1 to n do
if not(visit[i]) and (a[n,i]=1) then dfs(i);
end;
begin
ans:=0;
fillchar(a,sizeof(a),0);
fillchar(visit,sizeof(visit),false);
readln(n);
for i:=1 to n do
begin
x:=-1;
while x<>0 do
begin
read(x);
if x<>0 then begin a[x,i]:=1;a[i,x]:=1;end;
end;
end;
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]:3);
writeln;
end;
for i:=1 to n do
begin
if not(visit[i]) then begin dfs(i);inc(ans);end;
end;
writeln(ans);
end.
0 条评论
目前还没有评论...