package migong;
public class MiGong {
public static int[][] maze={{0,0,1,1,0,0,1,1},{0,0,0,0,1,1,1,1},{0,1,0,1,0,1,1,1},{0,0,0,0,0,0,0,0},{1,0,0,1,0,1,1,1},{0,0,1,0,0,1,1,0},{0,1,0,0,0,0,0,0,},{0,0,0,0,0,0,1,0}};
public static int dX[]={-1,0,1,0};//shang you xia left
public static int dY[]={0,1,0,-1};
public static boolean isFind=false;
public static int allmethods=0;
public static boolean isOut(int curx,int cury){
boolean result=true;
if(curx<0||curx>7||cury<0||cury>7)
result=false;
return result;
}
public static void dFS(int x,int y){
if(x==7&&y==7){
allmethods++;
isFind=true;
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
if(maze[i][j]==2)
System.out.print("#");
else
System.out.print(" ");
}
System.out.println("");
}
return ;
}
for(int i=0;i<4;i++){
int newX=x+dX[i];
int newY=y+dY[i];
if(isOut(newX,newY)&&maze[newX][newY]==0){
maze[newX][newY]=2;
dFS(newX,newY);
maze[newX][newY]=0;
}
}
}
public static void main(String[] args){
dFS(0,0);
System.out.println(" ");
System.out.println(allmethods);
if(isFind)
{
System.out.print("Success");
}else{
System.out.print("fail");
}
}
}