{$B-,Q-,R-,S-,I-}
{Programed By FR, Su 21/05/2006}
{Revisado, Tu 15/08/2006}
program robcom;{campo minado I}
{ ---variables--- }
var fe,fs : text;
m,n,k : byte;
c : array[0..101,0..101] of 0..1;
ox,oy,
dx,dy : byte;
ori : string[1]; { orientacion }
i,j : byte;
{ ---rutinas--- }
procedure inifiles;
begin
assign(fe,'robcom.dat');reset(fe);
assign(fs,'robcom.res');rewrite(fs);
end;
{----------------------------------------------------------------------------}
procedure closedfiles;
begin
close(fe);
close(fs);
end;
{----------------------------------------------------------------------------}
procedure readdata;
var line : string[200];
e : integer;
begin
readln(fe,line);
val(copy(line,1,pos(',',line)-1),m,e);
val(copy(line,pos(',',line)+1,length(line)),n,e);
fillchar(c,sizeof(c),1);
for m:=1 to m do begin
readln(fe,line);
while pos('0',line) > 0 do begin
c[m,pos('0',line) div 2 + 1] := 0;
line[pos('0',line)]:='1';
end;
end;
readln(fe,line); { origen }
val(copy(line,1,pos(',',line)-1),ox,e);
val(copy(line,pos(',',line)+1,length(line)),oy,e);
readln(fe,line); { destino }
val(copy(line,1,pos(',',line)-1),dx,e);
val(copy(line,pos(',',line)+1,length(line)),dy,e);
readln(fe,ori);
readln(fe,k)
end; { readdata }
{----------------------------------------------------------------------------}
procedure Check;
procedure no;
begin
write(fs,'E');
closedfiles;
halt;
end;
var fin : byte;
oper: char;
begin
fin:=2*k-1;
for i:=1 to fin do begin
read(fe,oper);
case oper of
'D' : begin
if ori = 'N' then ori:='E'
else
if ori = 'E' then ori:='S'
else
if ori = 'S' then ori:='O'
else
ori:='N'
end; {D}
'I' : begin
if ori = 'N' then ori:='O'
else
if ori = 'O' then ori:='S'
else
if ori = 'S' then ori:='E'
else
ori:='N'
end; {I}
'A' : begin
if ori = 'N' then begin
if c[ox-1,oy] = 1 then no
else
dec(ox);
end
else
if ori = 'E' then begin
if c[ox,oy+1] = 1 then no
else
inc(oy);
end
else
if ori = 'S' then begin
if c[ox+1,oy] = 1 then no
else
inc(ox);
end
else begin
if c[ox,oy-1] = 1 then no
else
dec(oy);
end
end; {A}
end { case }
end; { for k }
if (ox = dx) and (oy = dy) then
write(fs,'C')
else
write(fs,'E')
end; { check }
{----------------------------------------------------------------------------}
begin { program }
inifiles;
readdata;
check;
closedfiles;
end.
|