#include #define rep(i, a, n) for(int i = a; i < n; i++) #define int long long using namespace std; typedef pair P; const int mod = 1000000007; const int INF = 1e18; signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; vector a; rep(i, 0, n) a.push_back(i); int win = -1; vector > lose(n); while(1){ if(a.size() == 1){ win = a[0]; break; } vector b; for(int i = 0; i < a.size(); i += 2){ cout << "? " << a[i] + 1 << ' ' << a[i + 1] + 1 << endl; int in; cin >> in; in--; b.push_back(in); if(a[i] == in) lose[a[i]].push_back(a[i + 1]); else lose[a[i + 1]].push_back(a[i]); } if(a.size() % 2 == 1){ b.push_back(a.back()); } a = b; } int m = lose[win].size(); vector

c(m); rep(i, 0, m) c[i] = {0, lose[win][i]}; rep(i, 0, m){ rep(j, i + 1, m){ cout << "? " << lose[win][i] + 1 << ' ' << lose[win][j] + 1 << endl; int in; cin >> in; in--; if(in == lose[win][i]) c[i].first++; else c[j].first++; } } sort(c.rbegin(), c.rend()); cout << c[0].second + 1 << endl; }