#include #define ADD(a, b) a = (a + ll(b)) % mod #define MUL(a, b) a = (a * ll(b)) % mod #define MAX(a, b) a = max(a, b) #define MIN(a, b) a = min(a, b) #define rep(i, a, b) for(int i = int(a); i < int(b); i++) #define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--) #define all(a) (a).begin(), (a).end() #define sz(v) (int)(v).size() #define pb push_back #define sec second #define fst first #define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair pi; typedef pair pl; typedef pair ppi; typedef vector vi; typedef vector vl; typedef vector mat; typedef complex comp; void Debug() {cerr << '\n'; } templatevoid Debug(FIRST arg, REST... rest){ cerr<ostream& operator<<(ostream& out,const vector& v) { out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<ostream& operator<<(ostream& out,const pair& v){ out<<"("< vec; vector G[MAX_N]; int ask(int a, int b) { cout << "? " << a + 1 << " " << b + 1 << endl; int c; cin >> c; return c - 1; } int choose_fst(vector vec) { int f = vec[0]; rep(i, 1, sz(vec)) { int a = vec[i]; int c = ask(a, f); if(c == a) f = a; } return f; } pi choose_sec(vector vec) { int idx = rand() % sz(vec); int f = vec[idx]; vec.erase(vec.begin() + idx); vector cand; while(!vec.empty()) { vector nvec; idx = rand() % sz(vec); int d = vec[idx]; vec.erase(vec.begin() + idx); int c = ask(f, d); if(f == c) cand.pb(d); else { cand.clear(); cand.pb(f); f = d; } } return pi(f, choose_fst(cand)); } int erase_rand(vector& vec) { int idx = rand() % sz(vec); int b = vec[idx]; vec.erase(vec.begin() + idx); return b; } int choose_sec_rec(vector vec) { vector cand; vector bigger; rep(i, 0, 25) cand.pb(erase_rand(vec)); int f = choose_fst(cand); bigger.pb(f); rep(i, 0, sz(vec)) { if(vec[i] == ask(f, vec[i])) bigger.pb(vec[i]); } debug(sz(bigger), bigger); if(sz(bigger) >= 2) { return choose_sec(bigger).sec; } else exit(1); } void solve() { cin >> N; vector vec; rep(i, 0, N) vec.pb(i); srand((unsigned) time(NULL)); if(N <= 150) cout << "! " << choose_sec(vec).sec + 1 << "\n"; else cout << "! " << choose_sec_rec(vec) + 1 << "\n"; } int main() { solve(); }