Submission #1107809

#TimeUsernameProblemLanguageResultExecution timeMemory
1107809simona1230Colors (BOI20_colors)C++17
22 / 100
4 ms504 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; cout.flush(); return; } int nxt=curr+d; if(curr>h)nxt=curr-d; cout<<"? "<<nxt<<endl; cout.flush(); curr=nxt; cin>>x; } cout<<"= "<<d+1<<endl; cout.flush(); } else { while(x==0) { d++; if(d==n) { cout<<"= "<<d<<endl; cout.flush(); 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...