P7915 我写的deque暴力不输出
#include<bits/stdc++.h>
using namespace std;
int n;
deque<int> da,db;
deque<int> a,b;
int save[1005];
bool ok;
bool ceck(deque<int> qq){
while(!qq.empty()){
if(qq.front()!=qq.back()){
return false;
}
qq.pop_front();
qq.pop_back();
}
return true;
}
int tot=0;
// a's front to b's end del from a
// a's end to b's end del from a
void dfs(){
if(ceck(b)==true){
ok=true;
return;
}
int k;
k=a.front();
b.push_back(k);
a.pop_front();
dfs();
if(ok==true){
save[++tot]=1;
return ;
}
a.push_front(k);
k=a.back();
b.push_back(k);
a.pop_back();
dfs();
if(ok==true){
save[++tot]=2;
return ;
}
a.push_back(k);
}
int main(){
int T;
cin>>T;
while(T--){
tot=0;
ok=false;
while(!da.empty()) da.pop_back();
while(!db.empty()) db.pop_back();
cin>>n;
int x;
for(int i=1;i<=n/2;i++){
cin>>x;
a.push_back(x);
}
for(int i=1;i<=n/2;i++){
cin>>x;
b.push_back(x);
}
dfs();
if(ok==false){
cout<<-1<<endl;
}
else{
for(int i=tot;i>=1;i--){
if(save[i]==1){
cout<<'L';
}
else cout<<'R';
}
}
}
return 0;
}