Submission #361461

#TimeUsernameProblemLanguageResultExecution timeMemory
361461phathnvColors (BOI20_colors)C++11
0 / 100
1 ms512 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int Ask(int x){ cout << "? " << x << endl; int res; cin >> res; return res; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); ll n; cin >> n; ll l = 1, r = n - 1, start = 1, cur = -1, dir = -1; while (l <= r){ int mid = (l + r) >> 1; cur += mid * dir; dir *= -1; l = mid + 1; start = max(start, -cur); } l = 1, r = n - 1, cur = start, dir = -1; Ask(start); ll answer = n, delta = 0; while (l <= r){ int mid = (l + r) >> 1; cur += (mid + delta) * dir; dir *= -1; if (Ask(cur)){ answer = mid; l = mid + 1; } else { r = mid - 1; } } cout << "= " << answer << 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...