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