Submission #394273

# Submission time Handle Problem Language Result Execution time Memory
394273 2021-04-26T10:18:48 Z KoD Colors (BOI20_colors) C++17
0 / 100
1 ms 200 KB
#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 pos = 1;
    {
        int c = 0;
        ll x = N - 1;
        while (x > 1) {
            x /= 2;
            pos += c * x;
            c = 1 - c;
        }
    }
    ll ok = N, ng = 0;
    int dir = 1;
    ask(pos);
    ll last = 0;
    while (ok - ng > 1) {
        ll md = (ok + ng) / 2;
        if ((ok + ng) % 2 == 1 and last == ng) {
            md += 1;
        }
        last = md;
        pos += dir * md;
        dir = -dir;
        (ask(pos) ? ok : ng) = md;
    }
    std::cout << "= " << ok << std::endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Runtime error 1 ms 200 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Runtime error 1 ms 200 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Runtime error 1 ms 200 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Runtime error 1 ms 200 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB OK (4 queries)
2 Runtime error 1 ms 200 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -