This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n,a[200005],b[200005];
string s;
void dfs(int id,int as,int bs,string conf){
if (id==2*n){
cout<<conf<<"\n";
exit(0);
}
int tmp=0;
if (conf[id-1]=='A') tmp=a[id];
else tmp=b[id];
if (as<n && a[id+1]>=tmp) dfs(id+1,as+1,bs,conf+'A');
if (bs<n && b[id+1]>=tmp) dfs(id+1,as,bs+1,conf+'B');
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin>>n;
for (int i=1;i<=2*n;i++) cin>>a[i];
for (int i=1;i<=2*n;i++) cin>>b[i];
dfs(1,1,0,"A");
dfs(1,0,1,"B");
cout<<"-1\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |