比赛 |
noip20081103 |
评测结果 |
AWWTWWEEWA |
题目名称 |
花园栅栏 |
最终得分 |
20 |
用户昵称 |
苏轼 |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-03 21:57:47 |
显示代码纯文本
program cch(input,output);
const
xx:array[1..4] of integer=(1,0,-1,0);
yy:array[1..4] of integer=(0,1,0,-1);
chencch=110;
var
i,j,l,n,ans,x,y,x1,y1:integer;
ch:char;
area:array[0..900] of integer;
b:array[0..900] of boolean;
a:array[0..chencch,0..chencch] of integer;
procedure floodfill(x,y,color:integer);
var
i:integer;
begin
inc(area[color]);
a[x,y]:=color;
for i:=1 to 4 do
begin
x1:=x+xx[i];
y1:=y+yy[i];
if (x1>=0)and(x1<=chencch)and(y1>=0)and(y1<=chencch) then
if a[x1,y1]=0 then
floodfill(x1,y1,color);
end;
end;
begin
assign(input,'fence.in');
assign(output,'fence.out');
reset(input);
rewrite(output);
readln(x,y,n);
for i:=0 to chencch do
for j:=0 to chencch do a[i,j]:=0;
a[x,y]:=-1;
for i:=1 to n do
begin
readln(ch,l);
case ch of
'N':for j:=1 to l+1 do
begin
inc(x);
a[x,y]:=-1;
end;
'E':for j:=1 to l+1 do
begin
inc(y);
a[x,y]:=-1;
end;
'S':for j:=1 to l+1 do
begin
dec(x);
a[x,y]:=-1;
end;
'W':for j:=1 to l+1 do
begin
dec(y);
a[x,y]:=-1;
end;
end;
end;
area[0]:=0;
for i:=0 to chencch do
for j:=0 to chencch do
if a[i,j]=0 then
begin
inc(area[0]);
floodfill(i,j,area[0]);
end;
for i:=1 to area[0] do b[i]:=true;
for i:=0 to chencch do
begin
if a[0,i]<>-1 then b[a[0,i]]:=false;
if a[chencch,i]<>-1 then b[a[chencch,i]]:=false;
if a[i,0]<>-1 then b[a[i,0]]:=false;
if a[i,chencch]<>-1 then b[a[i,chencch]]:=false;
end;
ans:=0;
for i:=1 to area[0] do
if b[i] then
inc(ans,area[i]);
write(ans);
close(input);
close(output);
end.