#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int n; cin >> n; queue q; for(int i=1; i<=n; ++i) q.push(i); vector > edges(n+1); while(q.size() > 1){ int a = q.front(); q.pop(); int b = q.front(); q.pop(); cout << "? " << a << ' ' << b << endl; int x; cin >> x; if(a == x){ edges[a].push_back(b); q.push(a); } else{ edges[b].push_back(a); q.push(b); } } int victory = q.front(); q.pop(); for(int x : edges[victory]) q.push(x); while(q.size() > 1){ int a = q.front(); q.pop(); int b = q.front(); q.pop(); cout << "? " << a << ' ' << b << endl; int x; cin >> x; if(a == x) q.push(a); else q.push(b); } cout << "! " << q.front() << endl; return 0; }