#include #define pii pair #define x first #define y second using namespace std; const int dy[6] = {-1, +1, +2, +1, -1, -2}; const int dx[6] = {-2, -2, +0, +2, +2, +0}; const string encode[6] = {"UL", "UR", "R", "LR", "LL", "L"}; queue q; int trace[210][210], dis[210][210]; void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { // Print the distance along with the sequence of moves. while (q.size()) q.pop(); q.push(pii(i_start, j_start)); for (int i=0;i=n or v>=n) continue; if (dis[u][v]) continue; dis[u][v] = dis[x][y] + 1; trace[u][v] = i; q.push(pii(u, v)); } } if (!dis[i_end][j_end]){ cout << "Impossible"; } else { cout << dis[i_end][j_end]-1 << "\n"; vector res; while (i_end!=i_start or j_end!=j_start){ int idx = trace[i_end][j_end]; res.push_back(encode[idx]); i_end -= dx[idx]; j_end -= dy[idx]; } reverse(res.begin(), res.end()); for (int i=0;i> 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; }