Submission #392910

#TimeUsernameProblemLanguageResultExecution timeMemory
392910wind_reaperColors (BOI20_colors)C++17
100 / 100
6 ms396 KiB
#include <bits/stdc++.h> using namespace std; int Ask(int64_t num){ cout << "? " << num << endl; int x; cin >> x; return x; } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int64_t n; cin >> n; int64_t l = 1, r = n-1, start = n, cur = 0, dir = 1; while(l <= r){ int64_t mid = (l + r) / 2; cur += dir*mid; dir *= -1; start = min(start, n - cur); l = mid + 1; } l = 1, r = n-1, dir = 1; int64_t answer = n; Ask(start); while(l <= r){ int64_t mid = (l + r) / 2; int64_t ask = start + dir*mid; dir *= -1; if(Ask(ask)){ answer = mid; r = mid - 1; } else l = mid + 1; start = ask; } cout << "= " << answer << '\n'; 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...