Submission #553816

#TimeUsernameProblemLanguageResultExecution timeMemory
553816ArvinColors (BOI20_colors)C++11
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long set<ll> st; bool ask(ll n){ cout << "? " << n << endl; st.insert(n); int res; cin >> res; return (res == 1); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n; cin >> n; ll ans = n; ll pos = (n+1)/2; ask(pos); ll cur = 1; ll left = 1, right = n-1; while(left <= right){ ll mid = (left+right) >> 1; while(st.count(cur)){ cur++; } bool valid = false; if(pos-mid > 0 && !st.count(pos-mid)){ if(ask(pos-mid)){ valid = true; } else { valid = false; } pos -= mid; } else if(pos+mid <= n && !st.count(pos+mid)){ if(ask(pos+mid)){ valid = true; } else { valid = false; } pos += mid; } else { ask(cur); pos = cur; if(ask(pos+mid)){ valid = true; } else { valid = false; } pos += mid; } if(valid){ ans = mid; right = mid-1; } else { left = mid+1; } } cout << "= " << ans << 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...