이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "chameleon.h"
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<int, int>  pii;
typedef pair<ld, ld>  pld;
vector<int> pos[1009];
int ans[1009];
int okay(int x, int l, int r){
    vector<int> tmp;
    tmp.pb(x);
    for(int i = l; i <= r; ++i)
        tmp.pb(i);
    return Query(tmp) < tmp.size();
}
void binsearch(int x, int l, int r){
    if(l == r){
        pos[x].pb(l);
        return;
    }
    if(okay(x, l, (l+r)/2))
        binsearch(x, l, (l+r)/2);
    if(okay(x, (l+r)/2+1, r))
        binsearch(x, (l+r)/2+1, r);
}
int quad(int x){
    for(auto u : pos[x])
        if(pos[u].size() == 1) return u;
    if(Query({x, pos[x][0]}) == 1)
        return pos[x][0];
    else
        return pos[x][1];
}
void Solve(int n){
    for(int i = 1; i <= n; ++i)
        binsearch(i, n+1, 2*n);
    for(int i = n+1; i <= 2*n; ++i)
        binsearch(i, 1, n);
    for(int i = 1; i <= 2*n; ++i){
        if(ans[i]) continue;
        int okay[2] = {0, 0};
        for(int j = 0; j < 2; ++j){
            if(j >= pos[i].size() || ans[pos[i][j]]) continue;
            for(auto u : pos[pos[i][j]])
                if(u == i)
                    okay[j] = 1;
        }
        if(okay[0] && !okay[1]){
            ans[i] = pos[i][0];
            ans[pos[i][0]] = i;
        }
        else if(okay[1] && !okay[0]){
            ans[i] = pos[i][1];
            ans[pos[i][1]] = i;
        }
        else{   
            int k = quad(i);
            ans[i] = k;
            ans[k] = i;
        }
    }
    for(int i = 1; i <= n; ++i)
        Answer(i, ans[i]);
}
컴파일 시 표준 에러 (stderr) 메시지
chameleon.cpp: In function 'int okay(int, int, int)':
chameleon.cpp:22:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     return Query(tmp) < tmp.size();
            ~~~~~~~~~~~^~~~~~~~~~~~
chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:52:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(j >= pos[i].size() || ans[pos[i][j]]) continue;
                ~~^~~~~~~~~~~~~~~~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |