#include #define rep(i,a,b) for(int i=a;i=b;i--) #define fore(i,a) for(auto &i:a) #define all(x) (x).begin(),(x).end() //#pragma GCC optimize ("-O3") using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); } typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60; templatebool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } //--------------------------------------------------------------------------------------------------- int getrandmax() { static uint32_t y = time(NULL); y ^= (y << 13); y ^= (y >> 17); y ^= (y << 5); return abs((int)y); } int getrand(int l, int r) { // [l, r] return getrandmax() % (r - l + 1) + l; } vector makePermutation(int n, int loop = 101010) { vector v(n); rep(i, 0, n) v[i] = i + 1; rep(j, 0, loop) { int a = getrand(0, n - 1); int b = getrand(0, n - 1); swap(v[a], v[b]); } return v; } /*---------------------------------------------------------------------------------------------------             ∧_∧       ∧_∧  (´<_` )  Welcome to My Coding Space!      ( ´_ゝ`) /  ⌒i @hamayanhamayan     /   \    | |     /   / ̄ ̄ ̄ ̄/  |   __(__ニつ/  _/ .| .|____      \/____/ (u ⊃ ---------------------------------------------------------------------------------------------------*/ int N; //--------------------------------------------------------------------------------------------------- int forDebug[] = { -1, 2,4,1,3 }; bool isDebug = false; int ask(int x, int y) { if (isDebug) { int a, b; rep(i, 1, N + 1) if (forDebug[i] == x) { a = i; break; } rep(i, 1, N + 1) if (forDebug[i] == y) { b = i; break; } if (a < b) return x; return y; } printf("? %d %d\n", x, y); fflush(stdout); int res; cin >> res; return res; } void answer(int x) { printf("! %d\n", x); fflush(stdout); } //--------------------------------------------------------------------------------------------------- void _main() { cin >> N; auto per = makePermutation(N); int first, second; if (ask(per[0], per[1]) == per[0]) first = per[0], second = per[1]; else first = per[1], second = per[0]; rep(i, 2, N) { int x = per[i]; if (ask(first, x) == first) { if (ask(second, x) == x) { second = x; } } else { second = first; first = x; } } answer(second); }