记录编号 6672 评测结果 WWWWWWWWWA
题目名称 [USACO Dec08] 花园栅栏 最终得分 10
用户昵称 Gravatar王瑞祥K 是否通过 未通过
代码语言 Pascal 运行时间 0.018 s
提交时间 2008-11-03 22:32:29 内存使用 0.12 MiB
显示代码纯文本
program fence(input,output);
var
 map:array[0..100,0..100]of boolean;
 x,y,z,f:integer;
 d:char;
procedure ini;
var i,j:integer;
begin
 assign(input,'fence.in');assign(output,'fence.out');
 reset(input);rewrite(output);
 readln(x,y,z);
 fillchar(map,sizeof(map),false);
 for i:=1 to z do begin
  readln(d,f);
  case d of
  'N':for j:=1 to f do begin
       inc(y);
       map[x,y]:=true;
      end;
  'S':for j:=1 to f do begin
       dec(y);
       map[x,y]:=true;
      end;
  'E':for j:=1 to f do begin
       inc(x);
       map[x,y]:=true;
      end;
  'W':for j:=1 to f do begin
       dec(x);
       map[x,y]:=true;
      end;
  end;
 end;
end;
procedure main;
var i,j,k,m,max:integer;find:boolean;
begin
 for i:=0 to 100 do
  for j:=0 to 100 do
   if map[i,j]=true then begin
    find:=false;
    for k:=j+1 to 100 do
     if map[i,k]=true then begin find:=true;break;end;
    if find then for m:=j+1 to k-1 do map[i,m]:=true;
   end;
 max:=0;
 for i:=0 to 100 do
  for j:=0 to 100 do
   if (map[i,j])and(map[i,j+1])and(map[i+1,j]) then inc(max);
 write(max);
 close(input);close(output);
end;
begin
 ini;
 main;
end.