제출 #1322683

#제출 시각아이디문제언어결과실행 시간메모리
1322683Hamed_Ghaffari건물 4 (JOI20_building4)C++20
0 / 100
1 ms568 KiB
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; #define X first #define Y second #define lc id<<1 #define rc lc|1 #define mid ((l+r)>>1) #define all(x) x.begin(), x.end() #define SZ(x) int(x.size()) const int MXN = 5e5+5; int n, a[MXN], b[MXN]; int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(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]; int res=0; string ans=0; for(int i=1; i<=n; i++) if(a[i]>=res) { if(b[i]>=res) { if(a[i]<=b[i]) { res = a[i]; ans.push_back('A'); } else { res = b[i]; ans.push_back('B'); } } else res = a[i], ans.push_back('A'); } else if(b[i]>=res) res = b[i], ans.push_back('B'); else { cout << "-1\n"; return 0; } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...