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;
typedef long long ll;
typedef pair<int, int> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
// #pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lowbit(x) x&-x
const int maxn = 2e5 + 5;
const int INF = 1e9;
int n, Q;
int main(void){
fastio;
int n;
cin>>n;
n *= 2;
vector<int> a(n), b(n);
for(int i = 0; i < n; i++) cin>>a[i];
for(int i = 0; i < n; i++) cin>>b[i];
int pre = 0;
string ans = "";
for(int i = 0; i < n; i++){
if(pre > a[i] && pre > b[i]){
cout<<-1<<"\n";
return 0;
}
if(a[i] < b[i]){
if(pre <= a[i]) pre = a[i], ans += 'A';
else pre = b[i], ans += 'B';
}
else{
if(pre <= b[i]) pre = b[i], ans += 'B';
else pre = a[i], ans += 'A';
}
}
cout<<ans<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |