比赛 |
20120418s |
评测结果 |
AAAAAAAAAA |
题目名称 |
捉迷藏 |
最终得分 |
100 |
用户昵称 |
wo shi 刘畅 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2012-04-18 08:55:56 |
显示代码纯文本
- var
- n,m,total,i,x,y,min,max,ans:longint;
- v:array[0..1000000]of boolean;
- point,next,first,d,q:array[0..3000000]of longint;
-
- procedure addpage(x,y:longint);
- begin
- inc(total);
- point[total]:=y;
- next[total]:=first[x];
- first[x]:=total;
- end;
-
- procedure spfa;
- var
- i,h,t:longint;
- begin
- for i:=1 to n do d[i]:=maxlongint div 2;
- d[1]:=0;
- t:=1;
- q[1]:=1;
- v[1]:=true;
- h:=0;
- while h<>t do
- begin
- h:=(h mod n)+1;
- x:=q[h];
- i:=first[x];
- v[x]:=false;
- while i>0 do
- begin
- y:=point[i];
- if d[x]+1<d[y] then
- begin
- d[y]:=d[x]+1;
- if not v[y] then
- begin
- t:=(t mod n)+1;
- q[t]:=y;
- v[y]:=true;
- end;
- end;
- i:=next[i];
- end;
- end;
- end;
-
- begin
- assign(input,'hideseek.in'); reset(input);
- assign(output,'hideseek.out'); rewrite(output);
- readln(n,m);
- for i:=1 to m do
- begin
- readln(x,y);
- addpage(x,y);
- addpage(y,x);
- end;
- spfa;
- max:=-maxlongint;
- ans:=0;
- min:=maxlongint;
- for i:=2 to n do
- begin
- if d[i]>max then
- begin
- max:=d[i];
- ans:=1;
- min:=i;
- end
- else if d[i]=max then inc(ans);
- end;
- writeln(min,' ',max,' ',ans);
- close(input);
- close(output);
- end.