比赛 10101115 评测结果 AAAAATTTTT
题目名称 牛宫 最终得分 50
用户昵称 gragon 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-15 11:16:34
显示代码纯文本
program ex;
var
s:array[0..200,0..200]of real;
b,c,d:array[1..40000]of longint;
t,i,j,n,m,l,g:longint;
z,x:real;

procedure qk(l,r:longint);
var
i,j,m,t:longint;
begin
  i:=l;j:=r;m:=d[(l+r)div 2];
  repeat
  while d[i]>m do inc(i);
  while d[j]<m do dec(j);
  if i<=j then
  begin
    t:=d[i];
    d[i]:=d[j];
    d[j]:=t;
    t:=c[i];
    c[i]:=c[j];
    c[j]:=t;
    t:=b[i];
    b[i]:=b[j];
    b[j]:=t;
    inc(i);
    dec(j);
  end;
  until i>j;
  if i<r then qk(i,r);
  if j>l then qk(l,j);
end;

procedure init;
begin
  assign(input,'long.in');
  assign(output,'long.out');
  reset(input);
  rewrite(output);
  readln(n,m);
  t:=0;
  for i:=1 to n do
  begin
    z:=0;
    for j:=1 to m do
    begin
      read(x);
      s[i,j]:=s[i-1,j]+s[i,j-1]-s[i-1,j-1]+x;
      inc(t);
      b[t]:=i;c[t]:=j;d[t]:=i*j;
    end;
  end;
end;

begin
  init;
  qk(1,t);
  for l:=1 to t do
  begin
    for i:=1 to n-b[l]+1 do
    for j:=1 to m-c[l]+1 do
    begin
      z:=s[i+b[l]-1,j+c[l]-1]-s[i+b[l]-1,j-1]-s[i-1,j+c[l]-1]+s[i-1,j-1];
      if z>0 then
      begin
        writeln(d[l]);
        close(input);
        close(output);
        halt;
      end;
    end;
  end;
  writeln(0);
  close(input);
  close(output);
end.