# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
970289 | 2024-04-26T10:22:25 Z | maxFedorchuk | Colors (BOI20_colors) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; long long zap(long long zn) { cout<<"? "<<zn<<endl; cout.flush(); int rt; cin>>rt; return rt; } void ans(long long zn) { cout<<"= "<<zn<<endl; cout.flush(); } int main() { cin.tie(0); ios_base::sync_with_stdio(0); long long n; cin>>n; long long start=0,zr=0,l=1,r=n,o=-1; while(l<r) { l=(l+r-1)/2; zr+=o*l; start=max(start,1ll-zr); l++; o*=-1; } zap(start); l=1,r=n,o=-1; while(l<r) { long long mid=(l+r-1)/2; start+=mid*o; if(zap(start)) { r=mid; } else { l=mid+1; } } ans(l); return; }