이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
const ll mod = 1e9 + 7,inf = 1e18;
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void setIO()
{
    fast;
}
int main()
{
    setIO();
    int n;
    cin>>n;
    int m = 2 * n;
    vi a(m + 1),b(m + 1);
    for (int i = 1;i<=m;i++)cin>>a[i];for (int i = 1;i<=m;i++)cin>>b[i];
    vvi l(m + 1,vi(2,1e9)),h(m + 1,vi(2,-1e9));
    l[0][0] = l[0][1] = h[0][0] = h[0][1] = 0;
    for (int i = 1;i<=m;i++){
        if (a[i] >= a[i - 1])
            l[i][0] = min(l[i][0],l[i - 1][0] + 1),
            h[i][0] = max(h[i][0],h[i - 1][0] + 1);
        if (a[i] >= b[i - 1])
            l[i][0] = min(l[i][0],l[i - 1][1] + 1),
            h[i][0] = max(h[i][0],h[i - 1][1] + 1);
        if (b[i] >= a[i - 1])
            l[i][1] = min(l[i][1],l[i - 1][0]),
            h[i][1] = max(h[i][1],h[i - 1][0]);
        if (b[i] >= b[i - 1])
            l[i][1] = min(l[i][1],l[i - 1][1]),
            h[i][1] = max(h[i][1],h[i - 1][1]);
    }
    int i = m;
    if (l[i][0] <= n && n <= h[i][0]){
        vi out;
        int choice = 0;
        int numReq = n;
        while (i >= 1){
            out.pb(choice);
            if (choice == 0)numReq--;
            bool is = (choice == 0 ? a[i] >= a[i - 1] : b[i] >= a[i - 1]);
            if (l[i - 1][0] <= numReq && numReq <= h[i - 1][0] && is)
                choice = 0;
            else 
                choice = 1;
            i--;
        }
        reverse(out.begin(),out.end());
        for(auto it:out)cout<<(it ? "B" : "A");
    }
    else if (l[i][1] <= n && n <= h[i][1]){
        vi out;
        //out.pb(1);
        int choice = 1;
        int numReq = n;
        while (i >= 1){
            out.pb(choice);
            if (choice == 0)numReq--;
            bool is = (choice == 0 ? a[i] >= a[i - 1] : b[i] >= a[i - 1]);
            if (l[i - 1][0] <= numReq && numReq <= h[i - 1][0] && is)
                choice = 0;
            else
                choice = 1;
            i--;
        }
        reverse(out.begin(),out.end());
        for (auto it:out)cout<<(it == 0 ? "A" : "B");
    }
    else{
        cout<<-1;
    }
    return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
building4.cpp: In function 'int main()':
building4.cpp:27:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   27 |     for (int i = 1;i<=m;i++)cin>>a[i];for (int i = 1;i<=m;i++)cin>>b[i];
      |     ^~~
building4.cpp:27:39: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   27 |     for (int i = 1;i<=m;i++)cin>>a[i];for (int i = 1;i<=m;i++)cin>>b[i];
      |                                       ^~~| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |