level 7
var
ans,t,x,y,i,j,x1,y1,b,c:integer;
a:array[1..100,1..100] of 0..1;
procedure work(z:integer);
var
p,q,k:integer;
begin
if z=i*j-1 then begin
inc(ans);
writeln('no.',ans);
for b:=1 to i do begin
for c:=1 to j do write(a[b,c],' ');
writeln;
end;
exit;
end;
for k:=1 to 4 do begin
case k of
1:begin
p:=1; q:=0;
end;
2:begin
p:=0; q:=1;
end;
3:begin
p:=-1; q:=0;
end;
4:begin
p:=0; q:=-1;
end;
end;
if (x+p<=i) and (x+p>0) and (y+q<=j) and (y+q>0) then
if a[x+p,y+q]<>1 then begin
x:=x+p;
y:=y+q;
work(inc(t));
x:=x-p;
y:=y-q;
end;
end;
end;
begin
readln(i,j);
for b:=1 to i do
for c:=1 to j do
a[b,c]:=1;
readln(x,y);
readln(x1,y1);
a[x1,y1]:=1;
t:=0;
ans:=0;
work(t);
readln;
end.
2015年09月27日 10点09分