记录编号 |
49007 |
评测结果 |
AAAAAAAA |
题目名称 |
劣质的草 |
最终得分 |
100 |
用户昵称 |
digital-T |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.081 s |
提交时间 |
2012-11-07 08:11:30 |
内存使用 |
3.99 MiB |
显示代码纯文本
var
r,c,i,j,k,fresh:longint;
f:array[0..1001,0..1001]of longint;
procedure dfs(a,b:integer);
begin
f[a,b]:=fresh;
if f[a+1,b]=0 then dfs(a+1,b);
if f[a-1,b]=0 then dfs(a-1,b);
if f[a,b+1]=0 then dfs(a,b+1);
if f[a,b-1]=0 then dfs(a,b-1);
if f[a+1,b-1]=0 then dfs(a+1,b-1);
if f[a-1,b+1]=0 then dfs(a-1,b+1);
if f[a+1,b+1]=0 then dfs(a+1,b+1);
if f[a-1,b-1]=0 then dfs(a-1,b-1);
end;
begin
assign(input,'badgras.in');reset(input);
assign(output,'badgras.out');rewrite(output);
k:=0;
fresh:=0;
read(r,c);
for i:=1 to r do
for j:=1 to c do
begin
read(f[i,j]);
if f[i,j]=0 then f[i,j]:=-1;
if f[i,j]>0 then f[i,j]:=0;
end;
for i:=0 to r+1 do f[i,0]:=-1;
for j:=0 to c+1 do f[0,j]:=-1;
for i:=0 to r+1 do f[i,c+1]:=-1;
for j:=0 to c+1 do f[r+1,j]:=-1;
for i:=1 to r do
for j:=1 to c do
if f[i,j]=0 then
begin
inc(k);
inc(fresh);
dfs(i,j);
end;
write(fresh);
close(input);
close(output);
end.