/* ##################################################### # I will win.. maybe not immediately but definitely # ##################################################### */ #include using namespace std; //save time #define endl '\n' typedef long long ll; //for sorting #define all(a) a.begin(),a.end() //Constants #define PI 3.141592653593 #define MOD 1000000007LL #define EPS 0.000000001 //loops #define REP(i,n) for(int i=0;i<(n);++i) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define DFOR(i,a,b) for(int i=(a);i>=(b);--i) //vectors #define vi vector #define vll vector #define vii vector > #define pb push_back //pairs #define pi pair #define pll pair #define mp make_pair #define F first #define S second //fast I/O #ifndef _WIN32 #define getchar getchar_unlocked #define putchar putchar_unlocked #endif #define gc getchar #define pc putchar #define scan getFoo //If using cin and cout #define IOS ios::sync_with_stdio(false) #define TIE cin.tie(NULL) //queue #define di deque #define qi queue #define PQ priority_queue //general #define E empty() //Input methods template void getFoo(T &x){ x=0; register char c=gc(); for(;c<48 || c>57;c=gc()); for(;c>47 && c<58;c=gc()) x=(x<<1)+(x<<3)+c-48; } template void getFoo(T1 &x,T2 &y){ getFoo(x); getFoo(y); } template void getFoo(T1 &x,T2 &y,T3 &z){ getFoo(x); getFoo(y); getFoo(z); } //Declare all variables and methods needed between this comment and the next one(OCD lol) int n; pi startPos,endPos; bool vis[210][210]; pi prevPair[210][210]; string getDir(pi foo,pi bar){ int x1=foo.F,y1=foo.S,x2=bar.F,y2=bar.S; string ans=""; if(x1>x2) ans+="U"; else if(x1y2) ans+="L"; else ans+="R"; return ans; } bool isValid(pi p){ if(p.F>-1 && p.F-1 && p.S q; q.push(startPos); vis[startPos.F][startPos.S]=true; while(!q.E){ pi curr=q.front(); q.pop(); if(curr==endPos) break; pi positions[]={mp(curr.F-2,curr.S-1),mp(curr.F-2,curr.S+1),mp(curr.F,curr.S+2),mp(curr.F+2,curr.S+1),mp(curr.F+2,curr.S-1),mp(curr.F,curr.S-2)}; for(pi p : positions) if(isValid(p)){ prevPair[p.F][p.S]=curr; vis[p.F][p.S]=true; q.push(p); } } } //Code goes here !! int main(){ IOS; TIE; cin>>n>>startPos.F>>startPos.S>>endPos.F>>endPos.S; bfs(); if(vis[endPos.F][endPos.S]){ vector path; pi curr=endPos; while(curr.F!=startPos.F || curr.S!=startPos.S){ pi temp=prevPair[curr.F][curr.S]; path.pb(getDir(temp,curr)); curr=temp; } int pathSize=path.size(); cout<