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;
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#define per(i, l, r) for (int i = (r - 1); i >= l; --i)
#define ALL(x) (x).begin(), (x).end()
using i64 = long long;
void main_() {
int N;
cin >> N;
vector<pair<int, int>> s;
rep(i, 0, N) s.push_back({i, i});
rep(i, 0, N - 1) s.push_back({i, i + 1});
sort(ALL(s), [&](const auto a, const auto b) {
int x = 2 * min(a.first, N - a.second - 1);
if (a.first != a.second) ++x;
int y = 2 * min(b.first, N - b.second - 1);
if (b.first != b.second) ++y;
return x < y;
});
reverse(ALL(s));
int ans = 1;
for (const auto &[a, b] : s) {
int x = 2 * min(a, N - b - 1) + 2;
if (a == b) --x;
if (x < ans + 1) continue;
while (true) {
if (x < ans + 1) break;
int p = ans + 1;
if (x % 2 != p % 2) ++p;
if (p > x) break;
cout << '?';
int u = (p - 1) / 2;
cout << ' ' << a - u + 1 << ' ' << b + u + 1 << endl;
int res;
cin >> res;
if (res == 1) ans = p;
else break;
}
}
cout << '!' << ' ' << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
main_();
}
# | 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... |