이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
bool done[45];
int u[45],r[45];
int connect[45];
bool toret = false;
int N;
vector<pair<int,pair<int,int> > >c1;
vector<pair<int,pair<int,int> > >c2;
int X[45],Y[45];
void iterate(int n){
    if (n==N){
        printf("DA\n");
        for (int x = 0; x<n; x++){
            if (connect[x]!=-1){
                printf("%d %d\n",x+1,connect[x]+1);
            }
        }
        toret = true;
        return;
    }
    if (u[n]!=-1){
        bool can = true;
        for (auto x : c2){
            if (X[n]<=x.second.second && X[n]>=x.second.first && x.first<=max(Y[n],Y[u[n]]) && x.first>=min(Y[n],Y[u[n]])){
                can = false;
                break;
            }
        }
        if (can && !done[u[n]]){
            connect[n] = u[n];
            done[n] = true;
            done[u[n]] = true;
            int t = n+1;
            while (done[t]) t++;
            c1.push_back({X[n],{min(Y[n],Y[u[n]]),max(Y[n],Y[u[n]])}});
            iterate(t);
            c1.pop_back();
            connect[n] = -1;
            if (toret) return;
            done[n] = false;
            done[u[n]] = false;
        }
    }
    if (r[n]!=-1){
        bool can = true;
        for (auto x : c1){
            if (Y[n]<=x.second.second && Y[n]>=x.second.first && x.first<=max(X[n],X[u[n]]) && x.first>=min(X[n],X[u[n]])){
                can = false;
                break;
            }
        }
        if (can && !done[r[n]]){
            connect[n] = r[n];
            done[n] = true;
            done[r[n]] = true;
            int t = n+1;
            while (done[t]) t++;
            c2.push_back({Y[n],{min(X[n],X[u[n]]),max(X[n],X[u[n]])}});
            iterate(t);
            c2.pop_back();
            if (toret) return;
            connect[n] = -1;
            done[n] = false;
            done[r[n]] = false;
        }
    }
}
int main(){
    memset(r,-1,sizeof(r));
    memset(u,-1,sizeof(u));
    memset(connect,-1,sizeof(connect));
    int n;
    scanf("%d",&n);
    N=n;
    vector<pair<pair<int,int>,int> >v;
    vector<pair<pair<int,int>,int> > v2;
    for (int x = 0; x<n; x++){
        int a,b;
        scanf("%d%d",&a,&b);
        v.push_back({{a,b},x});
        v2.push_back({{b,a},x});
        X[x] = a;
        Y[x] = b;
    }
    sort(v.begin(),v.end());
    sort(v2.begin(),v2.end());
    for (int x = 1; x<n; x++){
        if (v[x].first.first==v[x-1].first.first){
            int t1 = min(v[x].second,v[x-1].second);
            int t2 = max(v[x].second,v[x-1].second);
            u[t1] = t2;
        }
    }
    for (int x = 1; x<n; x++){
        if (v2[x].first.first==v2[x-1].first.first){
            int t1 = min(v2[x].second,v2[x-1].second);
            int t2 = max(v2[x].second,v2[x-1].second);
            r[t1] = t2;
        }
    }
    iterate(0);
    if (toret) return 0;
    printf("NE");
}
컴파일 시 표준 에러 (stderr) 메시지
matching.cpp: In function 'int main()':
matching.cpp:79:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
matching.cpp:85:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&a,&b);
         ~~~~~^~~~~~~~~~~~~~| # | 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... |