Submission #492701

#TimeUsernameProblemLanguageResultExecution timeMemory
492701zhougzColors (BOI20_colors)C++17
0 / 100
1 ms200 KiB
/** * author: chowgz * created: 13/04/2021 20:13:22 **/ #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while (tt--) { long long n; cin >> n; long long l = 1, r = n - 1, m = (l + r) / 2; stack<long long> s; while (m != n - 1) { m = (l + r) / 2; s.push(m); l = m + 1; } long long cur = n; bool up = false; while (!s.empty()) { cur += up ? s.top() : -s.top(); up = !up; s.pop(); } bool yes; auto ask = [&](long long x) { cur += up ? x : -x; up = !up; cout << "? " << cur << endl; cout.flush(); cin >> yes; }; cout << "? " << cur << endl; cout.flush(); cin >> yes; l = 1; r = n - 1; m = (l + r) / 2; long long ans = n; while (l <= r) { ask(m); if (yes) { ans = m; r = m - 1; } else { l = m + 1; } m = (l + r) / 2; } cout << "= " << ans << endl; cout.flush(); } 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...