Submission #553917

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