Submission #930525

#TimeUsernameProblemLanguageResultExecution timeMemory
930525UmairAhmadMirzaColors (BOI20_colors)C++14
22 / 100
1 ms596 KiB
// Online C++ compiler to run C++ program online #include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; if(n>125) return 0; if(n==1){ cout<<"= "<<1<<endl; return 0; } bool r=0; int mid=(n/2)+1; cout<<"? "<<mid<<endl; cin>>r; cout<<"? "<<1<<endl; cin>>r; if(r==0){ r=1; int a=1,b=n+1; int i=0; while((b-a)>mid){ if(i){ a++; cout<<"? "<<a<<endl; cin>>r; if(r==0) break; } else{ b--; cout<<"? "<<b<<endl; cin>>r; if(r==0) break; } i^=1; } cout<<"= "<<(b-a)+!r<<endl; } else{ int a=1,b=mid; if(b==2){ cout<<"= "<<1<<endl; return 0; } for(int i=2;i<mid;i++){ if(i%2){ a++; cout<<"? "<<a<<endl; cin>>r; if(r==0) break; } else{ b--; cout<<"? "<<b<<endl; cin>>r; if(r==0) break; } } cout<<"= "<<(b-a)+!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...