比赛 20140418 评测结果 AWWWWWWWWW
题目名称 建造滑雪场 最终得分 10
用户昵称 zgyzhaoguangyang 运行时间 0.012 s
代码语言 Pascal 内存使用 0.24 MiB
提交时间 2014-04-18 09:14:54
显示代码纯文本
var
  a,b:array[-10..105,-10..105] of longint;
  n,m:longint;
procedure init;
var i,j:longint;
    jzw:char;
begin
  readln(n,m);
  for i:=1 to n do
    begin
      for j:=1 to m do
       begin
         read(jzw);
         if jzw='S' then a[i,j]:=1 else a[i,j]:=2;
       end;
     readln;
    end;
end;

procedure rolling_over(x,y,l,z:longint);
var i,j:longint;
begin
   for i:=x to x+l-1 do
      for j:=y to y+l-1 do
       b[i,j]:=z;
end;

function ok(l:longint):boolean;
var i,j:longint;
begin
   fillchar(b,sizeof(b),0);
   for i:=1 to (n-l+1) do
    begin
       for j:=1 to (m-l+1) do
        if b[i,j]<>a[i,j] then rolling_over(i,j,l,a[i,j]);
       for j:=m-l+2 to m do
        if b[i,j]<>a[i,j] then exit(false);
    end;
    for i:=n-l+2 to n do
      for j:=1 to m do
    if b[i,j]<>a[i,j] then exit(false);
  exit(true);
end;

procedure main;
var l,i:longint;
begin
    l:=n;
    if l>m then l:=m;
    for i:=l downto 1 do
     if ok(i) then break;
   writeln(i);
end;

begin
  assign(input,'skicourse.in');reset(input);
  assign(output,'skicourse.out');rewrite(output);
  init;main;
  close(input);close(output);
end.