Submission #446305

#TimeUsernameProblemLanguageResultExecution timeMemory
446305prvocisloColors (BOI20_colors)C++17
100 / 100
3 ms320 KiB
#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-1)/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-1)/2; s += d * mid; if (query(s)) hi = mid; else lo = mid+1; d *= -1; } cout << "= " << lo << endl; return 0; }
#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...