제출 #756981

#제출 시각아이디문제언어결과실행 시간메모리
756981Desh03건물 4 (JOI20_building4)C++17
0 / 100
2057 ms596 KiB
#include <bits/stdc++.h> using namespace std; int n; vector<int> A, B; bool ok; string ans, cur; void recurse(int i, int last, int cntA, int cntB) { if (ok || max(cntA, cntB) > n) return; if (i == (n << 1)) { ok = true; ans = cur; return; } if (A[i] >= last) { cur.push_back('A'); recurse(i + 1, A[i], cntA + 1, cntB); cur.pop_back(); } if (B[i] >= last) { cur.push_back('B'); recurse(i + 1, B[i], cntA, cntB + 1); cur.pop_back(); } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; A.resize(n << 1), B.resize(n << 1); for (int i = 0; i < (n << 1); i++) cin >> A[i]; for (int i = 0; i < (n << 1); i++) cin >> B[i]; recurse(0, -1, 0, 0); if (ok) { cout << ans << '\n'; } else { cout << "-1\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...