Submission #768858

# Submission time Handle Problem Language Result Execution time Memory
768858 2023-06-28T19:21:35 Z adrilen Colors (BOI20_colors) C++17
0 / 100
0 ms 208 KB
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using arr = array<int, 2>;
using arrr = array<int, 3>;

// mt19937 rng(1985022984);
ll last = -1;
set <ll> used = { -1 };

int query(int p)
{
    used.insert(p);
    cout << "? " << p << endl;
    int a;
    cin >> a;
    last = p;
    return a;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    
    ll n; 
    cin >> n;

    ll l = 1, r = n, mid;

    ll a, b, c, d;
    while (l != r)
    {
        mid = (l + r) >> 1;

        a = -1, b = -1;
        while (used.count(a) == 1 || used.count(b) == 1)
        {
            a = rand() % (n - mid);
            b = a + mid;
        }

        c = query(a);
        c++;
        
        d = query(b);
        if (d)
        {
            r = mid;
        } else {
            l = mid + 1;
        }
    }


    cout << "= " << l << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB OK (6 queries)
2 Runtime error 0 ms 208 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB OK (6 queries)
2 Runtime error 0 ms 208 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB OK (6 queries)
2 Runtime error 0 ms 208 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB OK (6 queries)
2 Runtime error 0 ms 208 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB OK (6 queries)
2 Runtime error 0 ms 208 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -