#include using namespace std; bool check(int n, vector> &v, int r, int c, int step) { if (r < 0 || c < 0 || r >= n || c >= n || v[r][c] == 0 || v[r][c] >= step) return false; return true; } void rec(vector> &sv, int i, int j, int i_start, int j_start) { if (i == i_start && j == j_start) return; if (sv[i][j] == "UL") { rec(sv, i+2, j+1, i_start, j_start); cout << "UL" << ' '; } else if (sv[i][j] == "UR") { rec(sv, i+2, j-1, i_start, j_start); cout << "UR" << ' '; } else if (sv[i][j] == "R") { rec(sv, i, j-2, i_start, j_start); cout << "R" << ' '; } else if (sv[i][j] == "LR") { rec(sv, i-2, j-1, i_start, j_start); cout << "LR" << ' '; } else if (sv[i][j] == "LL") { rec(sv, i-2, j+1, i_start, j_start); cout << "LL" << ' '; } else if (sv[i][j] == "L") { rec(sv, i, j+2, i_start, j_start); cout << "L" << ' '; } } 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. bool exit = false; string s = ""; vector> v(n, vector(n, 0)); vector> sv(n, vector(n)); v[i_start][j_start] = 1; while (!exit) { vector> curV = v; exit = true; 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; }