Submission #1097978

#TimeUsernameProblemLanguageResultExecution timeMemory
1097978MateiKing80Colors (BOI20_colors)C++17
100 / 100
2 ms600 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int ll bool query(int i) { cout << "? " << i << endl; cin >> i; return i; } signed main() { int n; cin >> n; int i = 0, c = 0, l = 1, r = n, d = -1; while(l < r) { l = (l + r - 1) / 2; c += d * l; l ++; i = max(i, 1LL - c); d *= -1; } query(i); l = 1, r = n, d = -1; while(l < r) { int m = (l + r - 1) / 2; i += d * m; if(query(i)) r = m; else l = m + 1; d *= -1; } cout << "= " << l << 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...