#include #include #include #include #include #include using namespace std; string a; queuepaths; struct cell { int x, y; int dis; cell() {} cell(int x, int y, int dis) : x(x), y(y), dis(dis) {} }; bool Inside(int x, int y, int N) { if (x >= 0 && x <= N-1 && y >= 0 && y <= N-1) return true; return false; } int minStep(int knightPos[2], int targetPos[2], int N) { int dy[] = {-2, -1, 1, 2, -1, 1}; int dx[] = {0, -2, -2, 0, 2, 2}; string val[] ={"L","UL","UR","R","LL","LR"}; queue q; q.push(cell(knightPos[0], knightPos[1], 0)); cell t; int x, y,i,j; bool visit[N][N]; for ( i = 0; i < N; i++) for ( j = 0; j < N; j++) visit[i][j] = false; visit[knightPos[0]][knightPos[1]] = true; int cnt=0; string s; int flag=0; while (!q.empty()) { t = q.front(); q.pop(); if(cnt>0) { s = paths.front(); paths.pop(); } visit[t.x][t.y] = true; cnt++; if (t.x == targetPos[0] && t.y == targetPos[1]) { a=s; flag=1; return t.dis; } if(flag==1) break; for (int i = 0; i < 6; i++) { x = t.x + dx[i]; y = t.y + dy[i]; if (Inside(x, y, N) && !visit[x][y]) { q.push(cell(x, y, t.dis + 1)); if(cnt-1==0) { paths.push(val[i]); } else { paths.push((s+" "+val[i])); } } } } return 0; } int main() { int n; int i,j=0; cin>>n; int kP[2]; int tP[2]; for( i=0;i<2;i++) { cin>>kP[i]; } for(i=0;i<2;i++) { cin>>tP[i]; } int val; val=minStep(kP, tP, n); if(val>0) { cout< d; for( i=0;i