#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "C:\debug.h"
#else
#define debug(...) 42
#endif
bool ask(int l, int r) {
cout << "? " << l + 1 << " " << r + 1 << endl;
bool x; cin >> x; return x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
int odd = 1, even = 0;
for (int i = 0; i < n; ++i) {
while (i - even >= 0 && i + 1 + even < n && ask(i - even, i + 1 + even)) ++even;
while (i - odd >= 0 && i + odd < n && ask(i - odd, i + odd)) ++odd;
}
cout << "! " << max(2 * even, 2 * odd - 1);
}
# | 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... |