why I got WA in 1033?
Послано
lilith 8 окт 2004 19:13
I think my program is correct, and I've checked it with the datas mentioned in the discuss.Would you please tell me what's wrong with my program? Thanks a lot!
First I find out the spaces which are reachable, then I count the sum of walls.
const poi:array[1..4,1..2]of shortint=((1,0),(0,1),(-1,0),(0,-1));
var i,j,k,t,n,m:longint;
map:array[1..33]of string;
form:array[1..33,1..33]of shortint;
wall:array[0..34,0..34]of shortint;
w:char;
procedure step(a,b:integer);
var i2,c,d:integer;
begin
if form[a,b]=0 then begin
form[a,b]:=1;
for i2:=1 to 4 do begin
c:=a+poi[i2,1];
d:=b+poi[i2,2];
if (c>0)and(c<=n)and(d>0)and(d<=n) then begin
if map[c,d]='.' then begin
step(c,d);
end;
end;
end;
end;
end;
begin
readln(n);
fillchar(map,sizeof(map),0);
for i:=1 to n do begin
map[i]:='';
for j:=1 to n do begin
read(w);
while (w<>'.')and(w<>'#') do read(w);
map[i]:=map[i]+w;
end;
readln;
end;
fillchar(form,sizeof(form),0);
step(1,1);
if form[n,n]=0 then step(n,n);
fillchar(wall,sizeof(wall),0);
for i:=1 to n do begin
for j:=1 to n do if form[i,j]=1 then begin
for k:=1 to 4 do begin
if form[i+poi[k,1],j+poi[k,2]]=0 then begin
inc(wall[i+poi[k,1],j+poi[k,2]]);
end;
end;
end;
end;
m:=0;
for i:=0 to n+1 do for j:=0 to n+1 do m:=m+wall[i,j];
m:=m-4;
writeln(m*9);
end.
Re: try testing your program on any simple test with N=33 (-)
Послано
lilith 9 окт 2004 06:16
Thx a lot! When I changed form to 0..34, it got AC!