2015年05月24日

88人阅读 评论(0)

program num8;
const n=1500;waymax=4;
dx:array[1..4]of longint=(0,1,0,-1);
dy:array[1..4]of longint=(1,0,-1,0);
type sh=array[1..3,1..3]of longint;
var state:array[1..n]of sh;
father,b:array[1..n]of longint;
yes:sh;
o:array[1..n,1..2]of longint;
can,succ:boolean;
procedure print(v:longint);
var buf:array[1..n]of longint;
m:longint;
begin
m:=0;
while v>0 do
begin
m:=m+1;
buf[m]:=v;
v:=father[v];
end;
for i:=m downto 1 do
begin
for j:=1 to 3 do
write(state[buf[i],j,k]:2);
writeln;
end;
//close(input);close(output);
end;
function check:boolean;
var i,j,k:longint;
begin
check:=true;
for k:=1 to top-1 do
for i:=1 to 3 do
for j:=1 to 3 do
if state[top,i,j]<>state[k,i,j] then exit(false);
end;
begin
//assign(input,'input.txt');
//assign(output,'output.txt');
//reset(input);
//rewrite(output);
for i:=1 to 3 do
begin
for j:=1 to 3 do
begin
end;
end;
for i:=1 to 3 do
begin
for j:=1 to 3 do
end;
repeat
for wayn:=1 to waymax do
begin
can:=true;
x:=xx+dx[wayn];y:=yy+dy[wayn];
if((x<1)or(x>3))or((y<1)or(y>3))then can:=false;
if can then
begin
o[top,1]:=x;o[top,2]:=y;
state[top,x,y]:=0;
if check then top:=top-1
else
begin
succ:=true;
for i:=1 to 3 do
for j:=1 to 3 do
if state[top,i,j]<>yes[i,j] then succ:=false;
if succ then begin
print(top);halt;end;
end;
end;
end;
end.
0
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：14996次
• 积分：107
• 等级：
• 排名：千里之外
• 原创：91篇
• 转载：0篇
• 译文：0篇
• 评论：0条
文章分类
文章存档
评论排行