Submission #446295

# Submission time Handle Problem Language Result Execution time Memory
446295 2021-07-21T13:53:17 Z prvocislo Colors (BOI20_colors) C++17
0 / 100
0 ms 200 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

//ll last = 0, c;
bool query(ll x) // vrati true ak C >= |x - last|
{
    cout << "? " << x << endl;
    int i; cin >> i;
    return i;
    /*ll dif = abs(x-last); last = x;
    cout << (c <= dif) << endl;
    return c <= dif;*/
}
int main()
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    ll n;
    cin >> n;
    //cin >> c;
    // najprv urobime fiktivne binarne vyhladavanie aby sme nasli dobru startovaciu poziciu
    ll lo = 1, hi = n, pos = -1, d = 1, s = pos;
    while (lo < hi)
    {
        ll mid = (lo+hi)/2;
        pos += d * mid;
        s = min(s, pos);
        lo = mid+1, d *= -1;
    }
    s = -s;
    // ok ideme robit realne binarne vyhladavanie, zaciname na s
    query(s);
    lo = 1, hi = n, d = 1;
    while (lo < hi)
    {
        ll mid = (lo+hi)/2;
        s += d * mid;
        if (query(s)) hi = mid;
        else lo = mid+1;
        d *= -1;
    }
    cout << "= " << lo << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -