#ifndef _Pbrngw_
#include "longesttrip.h"
#endif // _Pbrngw_
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(), (a).end()
#define task "kbsiudthw"
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 2277;
bool are_connected(vi A, vi B);
vector<int> longest_trip(int n, int D){
    if (D == 3){
        vi ans;
        FOR (i, 0, n - 1) ans.pb(i);
        return ans;
    }
    if (D == 2){
        deque<int> ans;
        ans.pb(0);
        vector<bool> marked(n, 0);
        marked[0] = 1;
        FOR (i, 1, n - 1){
            if (are_connected({0}, {i})){
                marked[i] = 1;
                ans.pb(i);
                break;
            }
        }
        FOR (i, 0, n - 1){
            if (marked[i]) continue;
            if (are_connected({ans.front()}, {i})){
                ans.push_front(i);
            } else ans.pb(i);
        }
        vi res;
        FOR (i, 0, n - 1) res.pb(ans[i]);
        assert(res.size() == n);
        return res;
    }
}
#ifdef _Pbrngw_
bool are_connected(vi A, vi B){
    cout << A[0] << ' ' << B[0] << endl;
    int x; cin >> x;
    return x;
}
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    vi ans = longest_trip(5, 2);
    for (int &x : ans) cout << x << ' ';
    return 0;
}
#endif // _Pbrngw_
컴파일 시 표준 에러 (stderr) 메시지
longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:54:1: warning: control reaches end of non-void function [-Wreturn-type]
   54 | }
      | ^| # | 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... |