#include using namespace std; int n, dp[201][201]; int i_start; int j_start; int i_end; int j_end; bool vis[201][201]; vector sol; int chec(int y, int x){ if(y < 0 || x < 0 || y >= n || x >= n || vis[y][x]) return 0; return 1; } int f(int y, int x){ if(y == i_end && x == j_end) return dp[y][x] = 0; if(dp[y][x] != -1) return dp[y][x]; vis[y][x] = 1; int ris = 1000; if(chec(y-2, x-1)) ris = min(ris, 1+f(y-2, x-1)); //UL if(chec(y-2, x+1)) ris = min(ris, 1+f(y-2, x+1)); //UR if(chec(y, x+2))ris = min(ris, 1+f(y, x+2)); //R if(chec(y+2, x+1)) ris = min(ris, 1+f(y+2, x+1)); //LR if(chec(y+2, x-1)) ris = min(ris, 1+f(y+2, x-1)); //LL if(chec(y, x-2))ris = min(ris, 1+f(y, x-2)); //L vis[y][x] = 0; return dp[y][x] = ris; } void back(int y, int x){ int ris = dp[y][x]; if(chec(y-2, x-1) && ris == 1+dp[y-2][x-1]){ sol.push_back("UL"); //UL back(y-2, x-1); return; } if(chec(y-2, x+1) && ris == 1+dp[y-2][x+1]){ sol.push_back("UR"); //UR back(y-2, x+1); return; } if(chec(y, x+2) && ris == 1+dp[y][x+2]){ sol.push_back("R");//R back(y, x+2); return; } if(chec(y+2, x+1) && ris == 1+dp[y+2][x+1]){ sol.push_back("LR"); //LR back(y+2, x+1); return; } if(chec(y+2, x-1) && ris == 1+dp[y+2][x-1]){ sol.push_back("LL"); //LL back(y+2, x-1); return; } if(chec(y, x-2) && ris == 1+dp[y][x-2]){ sol.push_back("L"); //L //cout << " nqernfvqer" << endl; back(y, x-2); return; } return ; } void printShortestPath() { memset(dp, -1, sizeof(dp)); int ris = f(i_start, j_start); if(ris >= 1000) { cout << "Impossible" << endl; return; } cout << f(i_start, j_start) << endl; back(i_start, j_start); //cout << sol.size() << endl; for(int i = 0; i> n; cin >> i_start >> j_start >> i_end >> j_end; printShortestPath(); return 0; }