Submission #999688

#TimeUsernameProblemLanguageResultExecution timeMemory
999688Mr_HusanboyColors (BOI20_colors)C++17
0 / 100
0 ms344 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define all(a) (a).begin(), (a).end() long long C; set<ll> st; ll last = -1; int _query = 0; int ask(ll x){ _query++; cout << "? " << x << endl; if(st.count(x)){ cout << " Used before!" << endl; exit(0); } st.insert(x); int res; #ifdef LOCAL res = (last == -1 || llabs(x - last) >= C ? 1 : 0); #else cin >> res; #endif last = x; return res; } void out(ll x){ cout << "= " << x << endl; #ifdef LOCAL assert(x == C); cout << _query << " queries called!"; #endif } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ll n; cin >> n; #ifdef LOCAL cin >> C; #endif ll l = 0, r = n; ll cur = 1; vector<ll> q; while(r - l > 1){ ll m = (l + r) / 2; q.push_back(m); l = m + 1; } reverse(all(q)); for(auto u : q){ if(cur + u <= n) cur += u; else cur -= u; } ask(cur); l = 0, r = n; while(r - l > 1){ ll m = (l + r) / 2; if(st.count(cur + m) || cur + m > n){ cur -= m; }else cur += m; if(ask(cur)){ r = m; }else l = m; } out(r); }
#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...