Submission #1030349

#TimeUsernameProblemLanguageResultExecution timeMemory
1030349thinknoexitColors (BOI20_colors)C++17
0 / 100
0 ms344 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll now = 0; bool ask(ll x) { now = x; cout << "? " << x << endl; cin >> x; return x; } void answer(ll x) { cout << "= " << x << endl; exit(0); } int main() { cin.tie(nullptr)->sync_with_stdio(false); ll n; cin >> n; ll l = 1, r = n; ask(1); while (l < r) { if (now == l) { if (ask(r)) l += 2; else answer(r - l + 1); } else { if (ask(l)) r -= 2; else answer(r - l + 1); } } if (now == l) { r += 2; // r - l == 1 if (r - l == 1) { answer(1); } else if (r - l == 2) { if (ask(r - 1)) answer(1); else answer(2); } } else { l -= 2; if (r - l == 1) { answer(1); } else if (r - l == 2) { if (ask(l + 1)) answer(1); else answer(2); } } 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...