记录编号 |
22022 |
评测结果 |
WWWWWWWWWW |
题目名称 |
剪切矩形 |
最终得分 |
0 |
用户昵称 |
itachi |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
0.472 s |
提交时间 |
2010-11-16 17:21:44 |
内存使用 |
1.45 MiB |
显示代码纯文本
program t3(input,output);
var
data:Array[1..1000,1..1000]of char;
h,s:array[1..1000,0..100]of integer;
n,m,i,j:integer; ans,temp:longint; flagh,flags:array[1..1000]of boolean;
function sum(a:integer):longint;
begin
sum:=(a+1)*a div 2 ;
end;
begin
assign(input,'rectangle.in');
reset(input);
assign(output,'rectangle.out');
rewrite(output);
ans:=0;
readln(n,m);
for i:= 1 to n do
begin
h[i,0]:=0;
flagh[i]:=false;
end;
for i:= 1 to m do
begin
s[i,0]:=0;
flags[i]:=false;
end;
for i:= 1 to n do
for j:= 1 to m do
begin
if j=m then readln(data[i,j])
else
read(data[i,j]);
if data[i,j]='.' then
begin
inc(ans);
if flagh[i]=false then
begin
inc(h[i,0]);
inc(h[i,h[i,0]] );
flagh[i]:=true;
end
else
inc(h[i,h[i,0]] );
if flags[j]=false then
begin
inc(s[j,0]);
inc(s[j,s[j,0]]);
flags[j]:=true;
end
else
inc(s[j,s[j,0]]);
end
else
begin
flagh[i]:=false;
flags[j]:=false;
end;
end;
close(input);
if ans=m*n then
begin
ans:=ans+sum(m-1)*n +sum(n-1)*m;
writeln(ans);
close(output);
halt;
end;
for i:= 1 to n do
for j:= 1 to h[i,0] do
begin
inc(ans,sum(h[i,j]-1));
end;
for i:= 1 to m do
for j:= 1 to s[i,0] do
inc(ans,sum(s[i,j]-1));
writeln(ans);
close(output);
end.