답안 #1091238

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1091238 2024-09-20T08:20:59 Z why_5_mins Colors (BOI20_colors) C++14
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

int n;

int getx()
{
    int st = 0, pas = 1ll << 60;
    while (pas != 0)
    {
        if (st + pas <= n)
        {
            int x = st + pas;
            bool oops = false;
            int l = 1, r = n, pass = -1;
            while (l < r)
            {
                int y;
                pass++;
                int rn = (r - l) / 2;
                if (pass % 2 == 0)
                    y = x + l + rn;
                else
                    y = x - l - rn;
                if (y > n)
                    oops = true;
                l = abs(x - y) + 1;
                x = y;
            }
            if (!oops)
                st += pas;
        }
        pas /= 2;
    }
    return st;
}

signed main()
{
    cin >> n;
    int x = getx();
    cout << "? " << x << endl;
    int rsp;
    cin >> rsp;
    int l = 1, r = n;
    int pas = -1;
    while (l < r)
    {
        int y;
        pas++;
        ///eu legit caut binar cu l si r, in ce hal am ajuns
        int rn = (r - l) / 2;
        if (pas % 2 == 0)
            y = x + l + rn;
        else
            y = x - l - rn;
        y = max(y, 0ll);
        y = min(y, n);
        cout << "? " << y << endl;
        if (y <= 0)
            assert(false);
        if (y > n)
            while(true);
        cin >> rsp;
        if (rsp == 0)
            l = abs(x - y) + 1;
        else
            r = abs(x - y);
        x = y;
    }
    cout << l;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Token parameter [name=cmd] equals to "4", doesn't correspond to pattern "[?=]"
2 Halted 0 ms 0 KB -