... dong}d:m_int;{d[i,j] - so o xoay it nhat de dua dongi ve trang thai j}{Danh cho tim cach xoay}bt,bd :byte;{bit tren, bit duoi}xmo :array[1..4]of tto; {xet 4trang thai tai mot o}trai,sbd,prex:array[1..nmax,1..4]of ... to 4 dobeginsbd[k,t]:=maxint;for s:=1 to 4 doif(xmo[t,1]=bt)and(xmo[t,2]=trai[k-1,s])and(xmo[t,3]=bd)and(sbd[k,t]>sbd[k-1,s]+x[t]) thenbeginsbd[k,t]:=sbd[k-1,s]+x[t];trai[k,t]:=xmo[t,4];prex[k,t]:=s;end;end;end;temp:=maxint;for ... nmax doif a[i]=1 thenbegint:=TinhGiaTri(x,i);if l[t]>l[i]+1 thenbegina[t]:=1; l[t]:=l[i]+1;pre[t]:=i; d[t]:=1; stop:=false;end;{---}t:=TinhGiaTri(i,x);if l[t]>l[i]+1 thenbegina[t]:=1; l[t]:=l[i]+1;pre[t]:=i;...