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[500001], B[500001];
int main() {
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> N;
for (int i = 1; i <= N * 2; ++i) cin >> A[i];
for (int i = 1; i <= N * 2; ++i) cin >> B[i];
int p = -1;
string ans;
for (int i = 1; i <= N * 2; ++i) {
int a = A[i], b = B[i];
if (a > b) swap(a, b);
if (p > b) return !printf("-1");
if (p <= a) p = a;
else p = b;
if (p == A[i]) ans.push_back('A');
else ans.push_back('B');
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |