답안 #804374

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
804374 2023-08-03T08:21:08 Z rnl42 Colors (BOI20_colors) C++14
0 / 100
1 ms 216 KB
#include <bits/stdc++.h>
using namespace std;

int N;

bool query(int x) {
    cout << "? " << x+1 << '\n' << flush;
    bool ret;
    cin >> ret;
    return ret;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> N;
    int mini = 0, maxi = N-1;
    int cur = N/3;
    query(cur);
    while (mini != maxi) {
        int mid = (mini+maxi)>>1;
        int size_interv = maxi-mini+1;
        int next;
        if (cur+mid < N) {
            next = cur+mid;
        } else if (cur+mid >= 0) {
            next = cur-mid;
        } else {
            query(N/3);
        }
        if (query(next)) {
            maxi = mid;
        } else {
            mini = mid+1;
        }
        cur = next;
    }
    cout << mini << '\n';
}

Compilation message

Colors.cpp: In function 'int main()':
Colors.cpp:21:13: warning: unused variable 'size_interv' [-Wunused-variable]
   21 |         int size_interv = maxi-mini+1;
      |             ^~~~~~~~~~~
Colors.cpp:30:18: warning: 'next' may be used uninitialized in this function [-Wmaybe-uninitialized]
   30 |         if (query(next)) {
      |             ~~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 216 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 216 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 216 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 216 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 216 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -