Submission #568481

#TimeUsernameProblemLanguageResultExecution timeMemory
568481losmi247Building 4 (JOI20_building4)C++14
0 / 100
1 ms340 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...