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;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
#define int long long
const int N = (int)1e6+10;
int n, a[2][N];
int32_t main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n;
for(int i = 0; i < 2*n; i++) cin >> a[0][i];
for(int i = 0; i < 2*n; i++) cin >> a[1][i];
for(int i = 0; i <= n; i++){
bool ok = 1; int prv = -1;
for(int j = 0; j < 2*n; j++){
if(j>=i and j<i+n) continue;
ok&=a[0][j]>=prv, prv=a[0][j];
}
prv=-1;
for(int j = i; j < i+n; j++)
ok&=a[1][j]>=prv, prv=a[1][j];
if(ok){
for(int j = 0; j < 2*n; j++)
cout << "AB"[j>=i and j<i+n];
cout << "\n";
return 0;
}
}
cout << -1 << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |