Submission #667149

#TimeUsernameProblemLanguageResultExecution timeMemory
667149Darren0724Colors (BOI20_colors)C++17
100 / 100
4 ms336 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define all(x) x.begin(),x.end() signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n;cin>>n; int l=0,r=n; vector<int> v; while(r-l>1){ int m=(l+r)>>1; v.push_back(m); l=m; } bool flag=0; int s=n; int n1=v.size(); for(int i=n1-1;i>=0;i--){ if(flag==0){ s-=v[i]; } else{ s+=v[i]; } flag^=1; } cout<<"? "<<s<<endl; int b=0; cin>>b; l=0,r=n; while(r-l>1){ int m=(l+r)>>1; if(flag==1){ s+=m; } else{ s-=m; } flag^=1; cout<<"? "<<s<<endl; int k;cin>>k; if(k==1){ r=m; } else{ l=m; } } cout<<"= "<<r<<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...