// #include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <set>
#include <deque>
using namespace std;
// #define int long long
// #define endl "\n"
#define fi first
#define se second
const int M=1203465797;
// const int inf = 1e14;
const int LOG=18;
const int N=2e5+5;
int n , m , c , w , k , t=1 , q=1 , x , y , z , l , r;
void solve(){
cin >> n;
int i=2;
int j=2;
int ans=1;
while (i<=n){
if (i-j+1<1){
i++;
continue;
}
cout << "? " << i-j+1 << " " << i << endl;
cin >> x;
if (x){
ans=max(ans,j);
j+=2;
}
else{
i++;
}
}
i=max(3,j-1);
j=max(3,j-1);
while (i<=n){
if (i-j+1<1){
i++;
continue;
}
cout << "? " << i-j+1 << " " << i << endl;
cin >> x;
if (x){
ans=max(ans,j);
j+=2;
}
else{
i++;
}
}
cout << "! ";
cout << ans << endl;
}
signed main()
{
// ios::sync_with_stdio(0);//DO NOT USE IN INTERACTIVE
// cin.tie(0), cout.tie(0);//DO NOT USE IN INTERACTIVE
// cout << fixed << setprecision(9);
// srand(time(0));
// int t=1;
// cin >> t;
for (int _=1;_<=t;_++){
solve();
q++;
}
}
// ghfedcabbacd
| # | 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... |