比赛 |
noip20081103 |
评测结果 |
AAAEAAAAAA |
题目名称 |
花园栅栏 |
最终得分 |
90 |
用户昵称 |
thegy |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-11-03 21:22:56 |
显示代码纯文本
program fence;
type
node=record
n,e,w,s:boolean;
end;
var
fin,fout:text;
x,y,z,i,j,a,tot:longint;
c:char;
g:array[0..101,0..101]of node;
v:array[0..101,0..101]of boolean;
procedure floodfill(x,y:longint);
begin
if v[x,y] then exit;
v[x,y]:=true;
if not(g[x,y].n) then floodfill(x+1,y);
if not(g[x,y].e) then floodfill(x,y+1);
if not(g[x,y].s) then floodfill(x-1,y);
if not(g[x,y].w) then floodfill(x,y-1);
end;
begin
assign(fin,'fence.in'); reset(fin);
assign(fout,'fence.out'); rewrite(fout);
for i:=0 to 101 do
for j:=0 to 101 do begin
g[i,j].n:=false;
g[i,j].w:=false;
g[i,j].s:=false;
g[i,j].e:=false;
end;
for i:=1 to 100 do begin
g[101,i].n:=true;
g[101,i].e:=true;
g[101,i].w:=true;
g[i,0].w:=true;
g[i,0].n:=true;
g[i,0].s:=true;
g[0,i].s:=true;
g[0,i].w:=true;
g[0,i].e:=true;
g[i,101].n:=true;
g[i,101].e:=true;
g[i,101].s:=true;
end;
readln(fin,x,y,z);
for i:=1 to z do begin
readln(fin,c,a);
if c='N' then begin
for j:=1 to a do begin
g[x+j,y].e:=true; g[x+j,y+1].w:=true;
end;
x:=x+a;
end;
if c='E' then begin
for j:=1 to a do begin
g[x+1,y+j].s:=true;
g[x,y+j].n:=true;
end;
y:=y+a;
end;
if c='S' then begin
for j:=1 to a do begin
g[x-j+1,y].e:=true; g[x-j+1,y+1].w:=true;
end;
x:=x-a;
end;
if c='W' then begin
for j:=1 to a do begin
g[x+1,y-j+1].s:=true;
g[x,y-j+1].n:=true;
end;
y:=y-a;
end;
end;
for i:=0 to 101 do
for j:=0 to 101 do begin
v[i,j]:=false;
end;
for i:=1 to 100 do begin
if not(v[101,i]) then floodfill(101,i);
if not(v[i,101]) then floodfill(i,101);
if not(v[0,i]) then floodfill(0,i);
if not(v[i,0]) then floodfill(i,0);
end;
tot:=0;
for i:=1 to 100 do
for j:=1 to 100 do begin
if v[i,j] then inc(tot);
end;
writeln(fout,10000-tot);
close(fin);
close(fout);
end.