自己测了好几个样例,都能过,点4就wa了
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#define endl "\n"
using namespace std;
map<int,string> sd;
int main(){
sd[1]='L';
sd[2]='R';
sd[3]='U';
sd[4]='D';
sd[5]="LU";
sd[6]="LD";
sd[7]="RU";
sd[8]="RD";
int s1,s2,t1,t2,tot=0,op[10005];
char ffgg,gghh;
cin>>ffgg>>s2>>gghh>>t2;
s1=ffgg-'a'+1;
t1=gghh-'a'+1;
while(s1!=t1&&s2!=t2){
if(s1>t1){
s1--;
if(s2<t2){
s2++;
op[++tot]=5;
}
else{
s2--;
op[++tot]=6;
}
}
else{
s1++;
if(s2<t2){
s2++;
op[++tot]=7;
}
else{
s2--;
op[++tot]=8;
}
}
}
if(s1==t1&&s2==t2){
cout<<tot<<endl;
for(int i=1;i<=tot;i++){
cout<<sd[op[i]]<<endl;
}
return 0;
}
if(s1==t1){
while(s2!=t2){
if(s2>t2){
op[++tot]=4;
s2--;
}
else{
op[++tot]=3;
s2++;
}
}
}
else{
while(s1!=t1){
if(s1>t1){
op[++tot]=4;
s1--;
}
else{
op[++tot]=3;
s1++;
}
}
}
cout<<tot<<endl;
for(int i=1;i<=tot;i++){
cout<<sd[op[i]]<<endl;
}
return 0;
}