This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
template<class T> using V = vector<T>;
using vi = V<int>;
int main() {
cin.tie(0)->sync_with_stdio(0);
int N; cin >> N;
auto ask = [&](int l, int r) {
if (l < 0 || r >= N) return 0;
cout << "? " << l + 1 << " " << r + 1 << endl;
int res; cin >> res; return res;
};
int odd = 0, even = 0;
for(int i = 0; i < N; i++) {
while(ask(i - odd - 1, i + odd + 1)) odd++;
while(ask(i - even, i - even + 1)) even++;
}
cout << "! " << max(2 * odd + 1, 2 * even) << endl;
exit(0-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... |