Submission #1107803

#TimeUsernameProblemLanguageResultExecution timeMemory
1107803simona1230Colors (BOI20_colors)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h> using namespace std; int n,j; pair<int,int> p[200001]; void prec() { int i=1; int l=1,r=n; while(l<r) { p[i]={l,r}; if(l==n-r+1)l++; else r--; if(r-l+1==n/2)j=i; if(i%2==0)swap(p[i].first,p[i].second); i++; } } void solve() { int i=j; cout<<"? "<<p[i].second<<endl; cout.flush(); int x; cin>>x; cout<<"? "<<p[i].first<<endl; cout.flush(); cin>>x; int curr=p[i].first; int d=abs(p[i].second-p[i].first); int h=n/2+n%2; if(x==1) { while(x==1) { d--; if(d==0) { cout<<"= "<<1<<endl; return; } int nxt=curr+d; if(curr>h)nxt=curr-d; cout<<"? "<<nxt<<endl; curr=nxt; cout.flush(); cin>>x; } cout<<"= "<<d<<endl; cout.flush(); } else { while(x==0) { d++; if(d==n) { cout<<"= "<<d<<endl; return; } int nxt=curr+d; if(curr>h)nxt=curr-d; cout<<"? "<<nxt<<endl; cout.flush(); curr=nxt; cin>>x; } cout<<"= "<<d<<endl; cout.flush(); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n; prec(); solve(); 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...