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 ll = long long;
bool ask(const ll x) {
std::cout << "? " << x << std::endl;
bool f;
std::cin >> f;
return f;
}
int main() {
ll N;
std::cin >> N;
ll len = N - 1;
ll pos = 1, dir = 1;
ask(pos);
while (len > 0) {
pos += len * dir;
dir = -dir;
if (!ask(pos)) {
std::cout << "= " << len + 1 << std::endl;
return 0;
}
len -= 1;
}
std::cout << "= " << 1 << std::endl;
// assert(N <= 125);
// if (N == 2) {
// ask(1);
// const auto ans = (ask(2) ? 1 : 2);
// std::cout << "= " << ans << std::endl;
// return 0;
// }
// ll half = (N - 1) / 2;
// ll other = (N - 1) - half;
// ll pos = 1 + (other + 1) / 2;
// ask(pos);
// pos += half;
// if (ask(pos)) {
// ll len = half;
// ll dir = -1;
// while (--len > 0) {
// pos += dir * len;
// dir *= -1;
// if (!ask(pos)) {
// break;
// }
// }
// std::cout << "= " << len + 1 << std::endl;
// }
// else {
// ll len = half;
// ll dir = -1;
// while (++len < N) {
// pos += dir * len;
// dir *= -1;
// if (ask(pos)) {
// break;
// }
// }
// std::cout << "= " << len << std::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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |