Submission #1036793

#TimeUsernameProblemLanguageResultExecution timeMemory
1036793MarwenElarbiColors (BOI20_colors)C++17
0 / 100
1 ms344 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define fi first #define se second #define int long long using namespace std; int query(int x){ cout <<"? "<<x<<endl; int ans; cin>>ans; return ans; } signed main(){ //setIO("closing"); int n; cin>>n; int l=0; int r=n; int pos=1; vector<int> tab; while(r-l>1){ tab.pb((r+l)/2); l=(r+l)/2; } for(auto u:tab) pos+=(pos+u <= n ? u : -u); map<int,bool> vis; l=0;r=n; vis[pos]=true; query(pos); while(r-l>1){ int mid=(r+l)/2; if(pos+mid<=n&&!vis[pos+mid]){ pos+=mid; }else pos-=mid; vis[pos]=1; if(query(pos)) r=mid; else l=mid; } cout <<"= "<<r<<endl; }
#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...