using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static void printShortestPath(int n, int i_start, int j_start, int i_end, int j_end) { int temp_i_start = i_start; int temp_j_start = j_start; int counter = 0; string step_string = ""; for(int i=0;i 1) || Math.Abs(temp_j_start - j_end) > 1 || Math.Abs(temp_j_start - j_end) == 0) { if(temp_i_start > i_end) { if(temp_j_start < j_end) { temp_i_start -= 2; temp_j_start += 1; //Console.WriteLine("UR"); if(step_string !="") { step_string += " UR"; } else { step_string += "UR"; } counter++; } else //if(temp_j_start > j_end) { temp_i_start -= 2; temp_j_start -= 1; //Console.WriteLine("UL"); if(step_string !="") { step_string += " UL"; } else { step_string += "UL"; } counter++; } } else if(temp_i_start == i_end) { if (temp_j_start > j_end) { temp_j_start -= 2; //Console.WriteLine("L"); if(step_string !="") { step_string += " L"; } else { step_string += "L"; } counter++; } else if(temp_j_start == j_end) { break; } else //if(temp_j_start < j_end) { temp_j_start += 2; //Console.WriteLine("R"); if(step_string !="") { step_string += " R"; } else { step_string += "R"; } counter++; } } else if(temp_i_start < i_end) { if(temp_j_start > j_end) { temp_i_start += 2; temp_j_start -= 1; //Console.WriteLine("LL"); if(step_string !="") { step_string += " LL"; } else { step_string += "LL"; } counter++; } else //if(temp_j_start < j_end) { temp_i_start += 2; temp_j_start += 1; //Console.WriteLine("LR"); if(step_string !="") { step_string += " LR"; } else { step_string += "LR"; } counter++; } } else { //Console.WriteLine("break"); break; } //Console.WriteLine("temp_i_start " + temp_i_start.ToString()); //Console.WriteLine("temp_j_start " + temp_j_start.ToString()); //Console.WriteLine("i_end " + i_end.ToString()); //Console.WriteLine("j_end " + j_end.ToString()); } else if(Math.Abs(temp_i_start - i_end) == 0 && Math.Abs(temp_j_start - j_end) == 0) { //Console.WriteLine("break"); break; } else { //Console.WriteLine("Impossible"); step_string = "Impossible"; counter=0; break; } } if(counter > 0) { Console.WriteLine(counter.ToString()); } Console.WriteLine(step_string); } static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); string[] tokens_i_start = Console.ReadLine().Split(' '); int i_start = Convert.ToInt32(tokens_i_start[0]); int j_start = Convert.ToInt32(tokens_i_start[1]); int i_end = Convert.ToInt32(tokens_i_start[2]); int j_end = Convert.ToInt32(tokens_i_start[3]); printShortestPath(n, i_start, j_start, i_end, j_end); } }