#include using namespace std; //do bfs int vis[200][200]; struct val{ int x;int y; int level; string dir; val *next; }; void print(val *temp){ vector ans; while(temp->dir!=""){ ans.push_back(temp->dir); temp=temp->next; } reverse(ans.begin(),ans.end()); for(int i=0;i=0&&x=0&&yx=x; vv->y=y; vv->level=l; vv->dir=s; } void count(int x2, int y2, int x1, int y1,int n){ queue q; val par; val *v=new val(); update(v,x1,y1,0,""); vis[x1][y1]=1; q.push(v); int f=0; while(!q.empty()){ // push in that order val *temp=q.front(); q.pop(); if(temp->x==x2&&temp->y==y2){ f=1; cout<level<<"\n"; print(temp); break; } if(vis[temp->x-2][temp->y-1]==0&&isSafe(temp->x-2, temp->y-1, n)){ val *vv=new val(); vis[temp->x-2][temp->y-1]=1; update(vv,temp->x-2,temp->y-1,temp->level+1,"UL"); vv->next=temp; q.push(vv); } if(vis[temp->x-2][temp->y+1]==0&&isSafe(temp->x-2, temp->y+1, n)){ val *vv=new val(); vis[temp->x-2][temp->y+1]=1; update(vv,temp->x-2,temp->y+1,temp->level+1,"UR"); vv->next=temp; q.push(vv); } if(vis[temp->x][temp->y+2]==0&&isSafe(temp->x, temp->y+2, n)){ val *vv=new val(); vis[temp->x][temp->y+2]=1; update(vv,temp->x,temp->y+2,temp->level+1,"R"); vv->next=temp; q.push(vv); } if(vis[temp->x+2][temp->y+1]==0&&isSafe(temp->x+2, temp->y+1, n)){ val *vv=new val(); vis[temp->x+2][temp->y+1]=1; update(vv,temp->x+2,temp->y+1,temp->level+1,"LR"); vv->next=temp; q.push(vv); } if(vis[temp->x+2][temp->y-1]==0&&isSafe(temp->x+2, temp->y-1, n)){ val *vv=new val(); vis[temp->x+2][temp->y-1]=1; update(vv,temp->x+2,temp->y-1,temp->level+1,"LL"); vv->next=temp; q.push(vv); } if(vis[temp->x][temp->y-2]==0&&isSafe(temp->x, temp->y-2, n)){ val *vv=new val(); vis[temp->x][temp->y-2]=1; update(vv,temp->x,temp->y-2,temp->level+1,"L"); vv->next=temp; q.push(vv); } } if(f==0) cout<<"Impossible\n"; } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n;cin>>n; int x1,y1,x2,y2; cin>>x1>>y1; cin>>x2>>y2; //start from end count(x2,y2,x1,y1,n); return 0; }