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;
const int N = 1e6+56;
int n,a[N],b[N],c[N];
int main(){
ios_base::sync_with_stdio(false);
cin.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];
}
string s = "";
for(int i = 1; i <= 2*n; i++){
if(a[i] < b[i]){
if(a[i] >= c[i-1]){
s += "A";
c[i] = a[i];
}
else{
if(b[i] < c[i-1]){
cout << -1 << endl;
return 0;
}
s += "B";
c[i] = b[i];
}
}
else{
if(b[i] >= c[i-1]){
s += "B";
c[i] = b[i];
}
else{
if(a[i] < c[i-1]){
cout << -1 << endl;
return 0;
}
s += "A";
c[i] = a[i];
}
}
}
cout << s << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |