比赛 |
20101116 |
评测结果 |
AATTTTTTTA |
题目名称 |
剪切矩形 |
最终得分 |
30 |
用户昵称 |
王者自由 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-16 10:55:55 |
显示代码纯文本
program rectangle;
var n,m,i,j:integer;
G:array[1..1000,1..1000]of 0..1;
F:array[0..1000,0..1000]of longint;
c:char; s:longint;
function Line(a,b:integer):longint;
var i:integer; w:longint;
begin
w:=-G[a,b];
for i:=1 to a do w+=G[i,b];
for i:=1 to b do w+=G[a,i];
exit(w);
end;
function Find(a,b:integer):longint;
var i,j:integer; w:longint;
begin
w:=0;
for i:=1 to n-a+1 do
for j:=1 to m-b+1 do
begin
if F[i+a-1,j+b-1]-F[i-1,j+b-1]-F[i+a-1,j-1]+F[i-1,j-1]=0
then w+=1;
end;
exit(w);
end;
begin
assign(input,'rectangle.in'); reset(input);
assign(output,'rectangle.out'); rewrite(output);
readln(n,m);
for i:=1 to n do
begin
for j:=1 to m do
begin
read(c);
if c='*' then G[i,j]:=1 else G[i,j]:=0;
end;
readln;
end;
F[0,0]:=0;
for i:=1 to n do
for j:=1 to m do
F[i,j]:=F[i-1,j-1]+Line(i,j);
s:=0;
for i:=1 to n do
for j:=1 to m do
s+=Find(i,j);
writeln(s);
close(input); close(output);
end.