Submission #1303393

#TimeUsernameProblemLanguageResultExecution timeMemory
1303393adaawfColors (BOI20_colors)C++20
0 / 100
0 ms332 KiB
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long int n;
    cin >> n;
    long long int l = 1, r = n - 1, h = 0, fl = 1, res;
    while (l <= r) {
        long long int mid = (l + r) >> 1;
        h += mid * fl;
        fl *= -1;
        if (mid <= n - 1) l = mid + 1;
        else r = mid - 1;
    }
    if (h > 0) h = n - h;
    else h = 1 - h;
    fl = 1; l = 1; r = n - 1;
    cout << "? " << h << endl;
    char x;
    cin >> x;
    while (l <= r) {
        long long int mid = (l + r) >> 1;
        h += fl * mid;
        fl *= -1;
        cout << "? " << h << endl;
        char x;
        cin >> x;
        if (x == '1') {
            res = mid;
            r = mid - 1;
        }
        else l = mid + 1;
    }
    cout << "! " << res << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...