Submission #803914

# Submission time Handle Problem Language Result Execution time Memory
803914 2023-08-03T06:32:43 Z thimote75 Colors (BOI20_colors) C++14
0 / 100
0 ms 316 KB
#include <bits/stdc++.h>

using namespace std;

bool query (int Q) {
    cout << "? " << Q << endl;

    int x; cin >> x;
    return x == 1;
}
int gen_start (int N) {
    // suppose N = C
    int a = 0; // a < C <= b
    int b = N;

    int pos = 0;
    int mpos = 0;
    bool f = false;
    while (b - a > 1) {
        int c = (a + b) >> 1;
        
        a = c;
        if (f) pos -= c;
        else pos += c;

        mpos = min(mpos, pos);
        f = !f;
    }

    return mpos;
}

int main () {
    int N;
    cin >> N;

    int mpos = - gen_start(N) + 1;
    query(mpos);

    int a = 0; // a < C <= b
    int b = N;

    bool delUp = true;
    int pos = mpos;
    while (b - a > 1) {
        int t = (a + b) >> 1;

        if (delUp) pos += t;
        else pos -= t;

        delUp = !delUp;

        if (query(pos)) a = t;
        else b = t;
    }

    cout << b << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 316 KB Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 316 KB Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 316 KB Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 316 KB Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 316 KB Token parameter [name=cmd] equals to "1", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -