比赛 20091103 评测结果 AAWWWWAAWWA
题目名称 乳草的入侵 最终得分 45
用户昵称 reamb 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-11-03 11:29:32
显示代码纯文本
  1. program caodituozhanwenti;
  2. var
  3. c,x,t,y,mx,w,my,i,j:integer;
  4. bz:boolean;
  5. a:array[0..101,0..101]of integer;
  6. b:char;
  7. begin
  8. assign (input,'milkweed.in');
  9. reset (input);
  10. assign (output,'milkweed.out');
  11. rewrite (output);
  12. readln (x,y,mx,my);
  13. for i:=1 to y do
  14. begin
  15. for j:=1 to x do
  16. begin
  17. read (b);
  18. if b='*' then
  19. begin
  20. a[i,j]:=0;
  21. w:=w+1
  22. end
  23. else
  24. a[i,j]:=-1
  25. end;
  26. readln
  27. end;
  28. a[mx,my]:=1;
  29. t:=t+1;
  30. repeat
  31. t:=t+1;
  32. bz:=true;
  33. for i:=1 to y do
  34. for j:=1 to x do
  35. if a[i,j]=t-1 then
  36. begin
  37. if a[i,j-1]=-1 then
  38. begin
  39. bz:=false;
  40. a[i,j-1]:=t
  41. end;
  42. if a[i,j+1]=-1 then
  43. begin
  44. bz:=false;
  45. a[i,j+1]:=t
  46. end;
  47. if a[i-1,j]=-1 then
  48. begin
  49. bz:=false;
  50. a[i-1,j]:=t
  51. end;
  52. if a[i+1,j]=-1 then
  53. begin
  54. bz:=false;
  55. a[i+1,j]:=t
  56. end;
  57. if a[i-1,j-1]=-1 then
  58. begin
  59. bz:=false;
  60. a[i-1,j-1]:=t
  61. end;
  62. if a[i-1,j+1]=-1 then
  63. begin
  64. bz:=false;
  65. a[i-1,j+1]:=t
  66. end;
  67. if a[i+1,j-1]=-1 then
  68. begin
  69. bz:=false;
  70. a[i+1,j-1]:=t
  71. end;
  72. if a[i+1,j+1]=-1 then
  73. begin
  74. bz:=false;
  75. a[i+1,j+1]:=t
  76. end
  77. end;
  78. if bz=true then
  79. begin
  80. writeln ('-1');
  81. close (input);
  82. close (output);
  83. halt
  84. end;
  85. c:=0;
  86. for i:=1 to y do
  87. for j:=1 to x do
  88. if a[i,j]>0
  89. then c:=c+1
  90. until c=x*y-w;
  91. writeln (t-1);
  92. close (input);
  93. close (output)
  94. end.