/* solver.c */ /* Last Change: 2018/08/26 (Sun) 21:47:11. */ #define MAX_ATTEMPS 100000 #include #include #include /* #include */ /* #include */ #include int board[8][72][72]={}; int avail[8][72][72]={}; //start=3,path=2,avail=1,nonavail=0,goal=-1 int connected[8*72*72/2+1]={}; //connected[0]=(number of connected lines) int depth,height,width; int goalx,goaly,goalz; int lines; //z,y,x void read(void){ //read problem int x,y,z,i; char c,str[8]; scanf(" %s",str); //SIZE scanf(" %d",&width); if(width>72||width<=0) printf("Error: width\n"); scanf(" %c",&c); //X scanf(" %d",&height); if(height>72||height<=0) printf("Error: height\n"); scanf(" %c",&c); //X scanf(" %d",&depth); if(depth>8||depth<=0) printf("Error: depth\n"); scanf(" %s",str); //LINE_NUM scanf(" %d",&lines); if(lines<=0) printf("Error: lines\n"); for(i=1;i<=lines;i++){ scanf(" %s",str); //LINE#X scanf(" %c",&c); //( scanf(" %d",&x); if(x>=72||x<0) printf("Error: x\n"); scanf(" %c",&c); //, scanf(" %d",&y); if(y>=72||y<0) printf("Error: y\n"); scanf(" %c",&c); //, scanf(" %d",&z); if(z>=72||z<0) printf("Error: z\n"); scanf(" %c",&c); //) board[z-1][y][x]=-i; scanf("%c",&c); //) /* scanf(" %[ -]",&c); //space or - */ scanf(" %c",&c); //( scanf(" %d",&x); if(x>=72||x<0) printf("Error: x\n"); scanf(" %c",&c); //, scanf(" %d",&y); if(y>=72||y<0) printf("Error: y\n"); scanf(" %c",&c); //, scanf(" %d",&z); if(z>=72||z<0) printf("Error: z\n"); scanf(" %c",&c); //) board[z-1][y][x]=-i; } return; } int randline(void){ //return random line number return rand()%lines+1; } void shuffle(int array[],int start,int end){ int i,j,t; if(end==start) return; for(i=start;igoalx){ searchorder[src]=0; src++; }else searchorder[5+src]=0; if(nowy>goaly){ searchorder[src]=1; src++; }else searchorder[4+src]=1; if(nowz>goalz){ searchorder[src]=2; src++; }else searchorder[3+src]=2; if(nowx0&&available(nowx-1,nowy,nowz)) return 1; break; case 1: if(nowy>0&&available(nowx,nowy-1,nowz)) return 1; break; case 2: if(nowz>0&&available(nowx,nowy,nowz-1)) return 1; break; case 3: if(nowx