答案

var
a,f:array[0..1001,0..1001] of int128;
x,i,j,n,m:longint; function min(a,b:longint):int128;
begin
if a<b then exit(a) else exit(b);
end;
begin
readln(n,m);
for i:=1 to n do
for j:=1 to m do read(a[i,j]);
for i:=1 to n do
for j:=1 to m do if a[i,j]=1 then
begin
f[i,j]:=min(min(f[i,j-1],f[i-1,j]),f[i-1,j-1])+1; if f[i,j]>x then
x:=f[i,j];
end;
writeln(x);
end.

4 条评论

  • @ 2016-12-31 15:38:16

    var
    a, f:array[0..1000, 0..1000] of longint;
    n, m, i, j, s:longint;
    function max(x, y:longint):longint;
    begin
    if x>y then max:=x
    else max:=y
    end;
    function min(x, y, z:longint):longint;
    begin
    if x<y then min:=x
    else min:=y;
    if z<min then min:=z
    end;
    begin
    readln(n, m);
    for i:=1 to n do
    for j:=1 to m do read(a[i, j]);
    s:=0;
    fillchar(f, sizeof(f), 0);
    for i:=1 to n do
    for j:=1 to m do if a[i, j]=1 then begin
    f[i, j]:=min(f[i-1, j], f[i, j-1], f[i-1, j-1])+1;
    s:=max(s, f[i, j])
    end;
    write(s)
    end.

  • @ 2016-12-14 14:38:31

    what

  • @ 2015-07-16 17:02:05

    不太懂

  • @ 2014-12-06 21:49:27

    请正确地发布源代码

  • 1

信息

ID
1057
难度
4
分类
动态规划 点击显示
标签
(无)
递交数
6668
已通过
3074
通过率
46%
被复制
8
上传者