比赛 20130729 评测结果 AAAATTTEEE
题目名称 捉迷藏 最终得分 40
用户昵称 FoolMike 运行时间 3.474 s
代码语言 Pascal 内存使用 95.56 MiB
提交时间 2014-07-17 09:51:31
显示代码纯文本
  1. var
  2. c,d,e,n,m:longint;
  3. a:array[1..10000,1..10000]of byte;
  4. f:array[1..10000]of integer;
  5. g:array[1..10000]of byte;
  6.  
  7. procedure ss(w,l:longint);
  8. var
  9. i:longint;
  10. begin
  11. if (w<>1)and((f[w]=0)or(l<f[w])) then f[w]:=l;
  12. for i:=1 to n do
  13. if (a[w,i]=1)and(g[i]=0) then
  14. begin
  15. g[i]:=1;
  16. ss(i,l+1);
  17. g[i]:=0;
  18. end;
  19. end;
  20.  
  21. begin
  22. assign(input,'hideseek.in');
  23. assign(output,'hideseek.out');
  24. reset(input);
  25. rewrite(output);
  26.  
  27. readln(n,m);
  28. for c:=1 to m do
  29. begin
  30. readln(d,e);
  31. a[d,e]:=1;
  32. a[e,d]:=1;
  33. end;
  34.  
  35. ss(1,0);
  36. e:=1;d:=0;
  37. for c:=2 to n do
  38. begin
  39. if f[c]>f[e] then
  40. begin
  41. e:=c;
  42. d:=0;
  43. end;
  44. if f[c]=f[e] then inc(d);
  45. end;
  46.  
  47. writeln(e,' ',f[e],' ',d);
  48. close(input);close(output);
  49. end.