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;
using pii = pair<int, int>;
int query(int l, int r) {
cout << "? " << l << " " << r << endl;
int x;
cin >> x;
return x;
}
int get1(int p, int d, int n) {
if(p - d < 1 || p + d > n) return 0;
return query(p - d, p + d);
}
int get2(int p, int d, int n) {
if(p - d + 1 < 1 || p + d > n) return 0;
return query(p - d + 1, p + d);
}
int main() {
int n, ans1=0, ans2=0;
cin >> n;
for(int i=1; i<=n; i++) while(get1(i, ans1+1, n)) ans1++;
for(int i=1; i+1<=n; i++) while(get2(i, ans2+1, n)) ans2++;
cout << "! " << max(2 * ans1 + 1, 2 * ans2) << endl;
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... |