답안 #804397

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

int N;
unordered_set<int> used;

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

signed 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 {
            int i;
            for (i = N/3; i >= 0 && used.count(i); i--);
            if (i != -1) {
                query(i);
                continue;
            }
            for (i = N/3+1; i < N && used.count(i); i++);
            query(i);
            continue;
        }
        if (query(next)) {
            maxi = mid;
        } else {
            mini = mid+1;
        }
        cur = next;
    }
    cout << "= " << mini << '\n';
}

Compilation message

Colors.cpp: In function 'int main()':
Colors.cpp:24:13: warning: unused variable 'size_interv' [-Wunused-variable]
   24 |         int size_interv = maxi-mini+1;
      |             ^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB OK (4 queries)
2 Correct 0 ms 208 KB OK (6 queries)
3 Correct 0 ms 208 KB OK (4 queries)
4 Incorrect 1 ms 208 KB Hair color 19 was used multiple times
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB OK (4 queries)
2 Correct 0 ms 208 KB OK (6 queries)
3 Correct 0 ms 208 KB OK (4 queries)
4 Incorrect 1 ms 208 KB Hair color 19 was used multiple times
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB OK (4 queries)
2 Correct 0 ms 208 KB OK (6 queries)
3 Correct 0 ms 208 KB OK (4 queries)
4 Incorrect 1 ms 208 KB Hair color 19 was used multiple times
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB OK (4 queries)
2 Correct 0 ms 208 KB OK (6 queries)
3 Correct 0 ms 208 KB OK (4 queries)
4 Incorrect 1 ms 208 KB Hair color 19 was used multiple times
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB OK (4 queries)
2 Correct 0 ms 208 KB OK (6 queries)
3 Correct 0 ms 208 KB OK (4 queries)
4 Incorrect 1 ms 208 KB Hair color 19 was used multiple times
5 Halted 0 ms 0 KB -