记录编号 |
112984 |
评测结果 |
AWWWWWWWWW |
题目名称 |
[USACO Open09] 捉迷藏 |
最终得分 |
10 |
用户昵称 |
转瞬の电流 |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
0.094 s |
提交时间 |
2014-07-17 21:58:23 |
内存使用 |
4.06 MiB |
显示代码纯文本
var
b:array[0..20000]of integer;
a:array[1..20000,0..100]of integer;
c,d,e,i,j,m,n,k,s:longint;
procedure pai(x,y:integer);
var
o,p,q,r:integer;
begin
p:=x;
q:=y;
o:=a[i,(x+y)div 2];
repeat
while a[i,p]<o do inc(p);
while a[i,q]>o do dec(q);
if p<=q then
begin
r:=a[i,p];
a[i,p]:=a[i,q];
a[i,q]:=r;
inc(p);
dec(q);
end;
until p>q;
if q>x then pai(x,q);
if p<y then pai(p,y);
end;
begin
assign(input,'hideseek.in');
assign(output,'hideseek.out');
reset(input);
rewrite(output);
readln(m,n);
for i:=1 to n do
begin
read(c,d);
if d<c then
begin
s:=d;
d:=c;
c:=s;
end;
e:=1;
while a[c,e]<>0 do
inc(e);
a[c,e]:=d;
end;
for i:=1 to m do
if a[i,1]<>0 then
begin
e:=0;
while a[i,e+1]<>0 do
e:=e+1;
if e>2 then
pai(1,e) else
if e=2 then
if a[i,2]<a[i,1] then
begin
s:=a[i,1];
a[i,1]:=a[i,2];
a[i,2]:=s;
end;
for j:=1 to e do
if (b[i]+1<b[a[i,j]])or(b[a[i,j]]=0) then b[a[i,j]]:=1+b[i];
end;
d:=0;
e:=0;
for i:=1 to m do
if b[i]>d then
begin
d:=b[i];
e:=i;
end;
for i:=1 to m do
if b[i]=d then inc(k);
writeln(e,' ',d,' ',k);
close(input);
close(output);
end.