记录编号 |
7835 |
评测结果 |
AAWWWWWEEEEEEEEAEEEE |
题目名称 |
奥术能量环流 |
最终得分 |
15 |
用户昵称 |
bing |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
0.086 s |
提交时间 |
2008-11-11 20:54:22 |
内存使用 |
2.02 MiB |
显示代码纯文本
program bing;
var
f1,f2:text;
n,m,ss:integer;
a:array[1..1000,1..1000] of integer;
b:array[1..1000] of integer;
c:array[1..1000] of boolean;
procedure init;
var
i,j,x:integer;
begin
assign(f1,'arcane.in');reset(F1);
assign(f2,'arcane.out');rewrite(f2);
readln(f1,n,m);
fillchar(a,sizeof(a),0);
fillchar(b,sizeof(b),0);
fillchar(c,sizeof(c),true);
ss:=0;
for i:=1 to n*m do
begin
read(f1,x);
if x in [1,3,5,7,9,11,13,15] then a[i,i+1]:=1;
if x in [2,3,6,7,10,11,14,15] then a[i,i-1]:=1;
if x in [4,5,6,7,12,13,14,15] then a[i,i+m]:=1;
if x in [8,9,10,11,12,13,14,15] then a[i,i-m]:=1;
end;
end;
procedure so1(i:integer);
begin
if c[i] then
begin
inc(b[i]);
if (b[i+1]=0)and(a[i,i+1]=1) then so1(i+1);
if (i-1>=0)and(b[i-1]=0)and(a[i,i-1]=1) then so1(i-1);
if (b[i+m]=0)and(a[i,i+m]=1) then so1(i+m);
if (i-m>=0)and(b[i-m]=0)and(a[i,i-m]=1) then so1(i-m);
end;
end;
procedure so2(i:integer);
begin
if c[i] then
begin
inc(b[i]);
if (a[i+1,i]=1)and(b[i+1]<>2) then so2(i+1);
if (i-1>=0)and(a[i-1,i]=1)and(b[i-1]<>2) then so2(i-1);
if (a[i+m,i]=1)and(b[i+m]<>2) then so2(i+m);
if (i-m>=0)and(a[i-m,i]=1)and(b[i-m]<>2) then so2(i-m);
end;
end;
procedure nb;
var
i,j,s:integer;
begin
for i:=1 to m*n do
if c[i] then
begin
s:=0;
so1(i);
so2(i);
for j:=1 to m*n do
begin
if b[j]=2 then begin c[j]:=false;inc(s);end;
b[j]:=0;
end;
if s>1 then inc(ss);
end;
end;
begin
init;
nb;
write(f2,ss);
close(f1);close(f2);
end.