This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
bool ask(int l, int r){
cout << "? " << l << ' ' << r;
cout << endl;
int t; cin >> t;
return t;
}
void answer(int L){
cout << "! " << L;
cout << endl;
}
void solve(){
int n; cin >> n;
int ans = 1;
for (int i = 1; i <= n; ++ i){
while (i - ans >= 1 && i + ans <= n && ask(i - ans, i + ans)) ++ ans;
}
int res = 2 * ans - 1;
for (int i = 1; i <= n; ++ i){
while (i - ans + 1 >= 1 && i + ans <= n && ask(i - ans + 1, i + ans)) ++ ans, res = max(res, 2 * ans - 2);
}
answer(res);
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}
# | 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... |