JasonX 2011-10-27 06:41:00
点我顶贴
收藏
删除
var
p,q,x,y,max,s,i,j,n,m:longint;
f:array[1..2000] of longint;
w:array[1..2000] of longint;
function zxc(o:longint):longint;
begin
if f[o]=o then
exit(o)
else
begin
zxc:=zxc(f[o]);
f[o]:=zxc;
end;
end;
begin
read(n,m);
for i:=1 to n do
f[i]:=i;
for i:=1 to m do
begin
read(x,y);
p:=zxc(x);
q:=zxc(y);
if p<>q then
f[y]:=p;
end;
max:=0;
fillchar(w,sizeof(w),0);
for i:=1 to n do
begin
p:=zxc(i);
w[p]:=w[p]+1;
end;
for i:=1 to n do
if w[i]>max then
max:=w[i];
writeln(max);
end.
有效耗时: 125毫秒
测试结果1: 通过本测试点|有效耗时62ms
测试结果2: 通过本测试点|有效耗时63ms
测试结果3: 测试结果错误.错误结果为:4
正确结果应为:6
测试结果4: 测试结果错误.错误结果为:7
正确结果应为:15
测试结果5: 测试结果错误.错误结果为:13
正确结果应为:90