#include using namespace std; #define F first #define S second pair moves[] = {{-2,-1},{-2,1},{0,2},{2,1},{2,-1},{0,-2}}; string moves1[] = {"UL","UR","R","LR","LL","L"}; bool is_safe(int s1,int s2,int n){ if(s1=0 and s2>=0) return true; return false; } string get_move(pair &s,pair &e){ for(int i=0;i<6;++i){ if(s.F+moves[i].F==e.F and s.S+moves[i].S==e.S) return moves1[i]; } return "+"; } int start(int s1,int s2,int e1,int e2,int n,vector > &cost,vector > > &path){ queue > q; q.push({s1,s2}); cost[s1][s2] = 0; while(!q.empty()){ pair s = q.front(); q.pop(); if(s.F==e1 and s.S==e2) break; for(int i=0;i<6;++i){ int s1_1 = s.F + moves[i].F; int s2_1 = s.S + moves[i].S; if(is_safe(s1_1,s2_1,n) and cost[s1_1][s2_1]==-1){ q.push({s1_1,s2_1}); //cout<<"at "< > cost(n,vector(n,-1)); vector > > path(n,vector >(n)); int x = start(i_start,j_start,i_end,j_end,n,cost,path); if(x==-1){ cout<<"Impossible"< str; pair e = {i_end,j_end}; while(e!=make_pair(i_start,j_start)){ //cout<<"from "<> 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; }