#include #include #include #include using namespace std; int n , moves = 0; int i_start; int j_start; int i_end; int j_end; vector path; struct board{ bool visited = 0; unsigned short int x,y,par_x,par_y; /*void operator = (const board &dum){ visited = dum.visited; x = dum.x; y = dum.y; par_x = dum.par_x; par_y = dum.par_y; }*/ }; board newb[200][200]; queue moverq; bool out_of_bounds(int x, int y){ if(x < 0 || y < 0 || x > n-1 || y > n-1) return true; else return false; } int backtrace(int x, int y){ board now = newb[x][y]; if(now.par_x == -1 && now.par_y == -1) return 1; if(x - now.par_x == -2 && y - now.par_y == -1){ path.push_back("UL"); moves++; int UL = backtrace(x+2, y+1); } else if(x - now.par_x == -2 && y - now.par_y == 1){ path.push_back("UR"); moves++; int UR = backtrace(x+2, y-1); } else if(x - now.par_x == 0 && y - now.par_y == -2){ path.push_back("L"); moves++; int L = backtrace(x, y+2); } else if(x - now.par_x == 0 && y - now.par_y ==2){ path.push_back("R"); moves++; int R = backtrace(x, y-2); } else if(x - now.par_x == 2 && y - now.par_y ==-1){ path.push_back("LL"); moves++; int LL = backtrace(x-2, y+1); } else if(x - now.par_x == 2 && y - now.par_y == 1){ path.push_back("LR"); moves++; int LR = backtrace(x-2, y-1); } return 0; } void visit(int x, int y, int parent_x, int parent_y){ if(!out_of_bounds(x,y)){ //cout<=0; i--) cout<>n; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ newb[i][j].x = i; newb[i][j].y = j; } } cin >> i_start >> j_start >> i_end >> j_end; printShortestPath(n, i_start, j_start, i_end, j_end); return 0; }