#include #include #include #include #include using namespace std; const int MAX = 9,limit = 6,INF = 1000; const int dirx[4]={0,-1,0,1},diry[4]={1,0,-1,0}; int map[MAX][MAX][4]; int dist[MAX][MAX],pre[MAX][MAX][2]; int sx,sy,ex,ey,pax,pay,pbx,pby; stack st; void init(){ int i,j; for(i=0;ilimit || ty>limit)continue; if(cnt+1>dist[tx][ty])continue; dist[tx][ty] = cnt; pre[tx][ty][0] = x; pre[tx][ty][1] = y; dfs(tx,ty,cnt+1); } } void Path(){ int px,py,x,y; x = ex,y = ey; px = pre[x][y][0]; py = pre[x][y][1]; while(1){ if(x==px){ if(py