Submission #361471

#TimeUsernameProblemLanguageResultExecution timeMemory
361471phathnvColors (BOI20_colors)C++11
100 / 100
90 ms512 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; } 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){ ll 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; while (l <= r){ ll mid = (l + r) >> 1; cur += mid * dir; dir *= -1; if (Ask(cur)){ answer = mid; r = mid - 1; } else { l = 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...