#include using namespace std; struct position { int x; int y; }; void set_distance(vector temp,position end,vector > &visited,int n) { vector next; while(temp.size()!=0) { int i,j; position front = temp.front(); i = front.x; j= front.y; if(i==end.x && j==end.y) { return; } temp.erase(temp.begin()); int count = visited[i][j]+1; if(j-2>=0) { if(visited[i][j-2]==0) { visited[i][j-2]=count; position n; n.x = i; n.y = j-2; next.push_back(n); } } if(j-1>=0) { if(i-2>=0) { if(visited[i-2][j-1]==0) { visited[i-2][j-1] = count; position n1; n1.x = i-2; n1.y = j-1; next.push_back(n1); } } if(i+2=0) { if(visited[i-2][j+1]==0) { visited[i-2][j+1]=count; position n4; n4.x = i-2; n4.y = j+1; next.push_back(n4); } } if(i+2 > visited(n,vector(n)); for(int i=0;i que; position temp; temp.x = i_end; temp.y = j_end; position end; end.x = i_start; end.y = j_start; que.push_back(temp); set_distance(que,end,visited,n); /* for(int i=0;i ans; while(count!=0) { if(x-2>=0) { if(y-1>=0) { if(visited[x-2][y-1]==count) { cout<<"UL"<<" "; count--; x=x-2; y=y-1; continue; } } if(y+1=0) { if(visited[x+2][y-1]==count) { cout<<"LL"<<" "; count--; x=x+2; y=y-1; continue; } } } if(y-2>=0) { if(visited[x][y-2]==count) { count--; cout<<"L"<<" "; y=y-2; } } } cout<> n; int i_start; int j_start; int i_end; int j_end; cin >> i_start >> j_start >> i_end >> j_end; printShortestPath(n, i_start, j_start, i_end, j_end); return 0; }