답안 #394307

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
394307 2021-04-26T11:36:21 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;
    assert(N <= 125);
    if (N == 2) {
        ask(1);
        std::cout << "= " << (ask(2) ? 1 : 2) << '\n';
        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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB OK (3 queries)
2 Correct 1 ms 200 KB OK (23 queries)
3 Correct 1 ms 200 KB OK (5 queries)
4 Runtime error 1 ms 200 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB OK (3 queries)
2 Correct 1 ms 200 KB OK (23 queries)
3 Correct 1 ms 200 KB OK (5 queries)
4 Runtime error 1 ms 200 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB OK (3 queries)
2 Correct 1 ms 200 KB OK (23 queries)
3 Correct 1 ms 200 KB OK (5 queries)
4 Runtime error 1 ms 200 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB OK (3 queries)
2 Correct 1 ms 200 KB OK (23 queries)
3 Correct 1 ms 200 KB OK (5 queries)
4 Runtime error 1 ms 200 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB OK (3 queries)
2 Correct 1 ms 200 KB OK (23 queries)
3 Correct 1 ms 200 KB OK (5 queries)
4 Runtime error 1 ms 200 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -