Submission #1101166

#TimeUsernameProblemLanguageResultExecution timeMemory
1101166NoMercyColors (BOI20_colors)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int ask (ll x) { cout << "? " << x << endl; int res; cin >> res; return res; } int32_t main () { // ios_base::sync_with_stdio(0); // cin.tie(0); // cout.tie(0); ll N; cin >> N; ll lo = 0, hi = N + 1, query = 0; ask(1); ll ind = 1; while (lo + 1 < hi) { // if (query == 64) assert(0); query ++; ll mid = (lo + hi) >> 1; // cout << lo << " " << mid << " " << hi << " " << ind << "\n"; if (ind - mid >= 1) { if (ask (ind - mid) == 1) { hi = mid; } else { lo = mid; } ind = ind - mid; } else if (ind + mid <= N) { if (ask (ind + mid) == 1) { hi = mid; } else { lo = mid; } ind = ind + mid; } else { if (ind - 1 >= N - ind) { if (ask(1) == 1) { hi = ind - 1; } else { lo = ind - 1; } ind = 1; } else { if (ask(N) == 1) { hi = N - ind; } else { lo = N - ind; } ind = N; } } } cout << "= " << hi << 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...