Submission #357683

#TimeUsernameProblemLanguageResultExecution timeMemory
357683leinad2Colors (BOI20_colors)C++17
0 / 100
1 ms364 KiB
#include<bits/stdc++.h> using namespace std; int n, b, i, j, k, c, chk[111], x, y, prv, cnt; int ask(int x) { cout<<"? "<<x<<endl; int ret; cin>>ret; return ret; } int main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin>>n; b=(int)sqrt(n); vector<int>v; for(i=1;i<n;i+=b)v.push_back(i); x=(n-v.back()+1)/2; for(i=0;i<v.size();i++)v[i]+=x; for(k=1;;k++) { i=k/2; if(k%2)j=i; else j=v.size()-i; if(chk[v[j]])break; int ret=ask(v[j]); prv=v[j]; if(k==1)continue; if(ret==0) { if(k%2==0)c=v.size()-2*i+1; else c=v.size()-2*i; break; } } v.clear(); x=c*b+1; y=min((c+1)*b, n-1); if(2*prv>n)cnt=-1; else cnt=1; for(i=x;i<=y;i++) { int ret=ask(prv+cnt*i); prv+=cnt*i; cnt=-cnt; if(ret)break; } cout<<"= "<<i; }

Compilation message (stderr)

Colors.cpp: In function 'int main()':
Colors.cpp:19:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(i=0;i<v.size();i++)v[i]+=x;
      |             ~^~~~~~~~~
#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...