Submission #749948

#TimeUsernameProblemLanguageResultExecution timeMemory
749948vjudge1Carnival (CEOI14_carnival)C++17
0 / 100
0 ms208 KiB
#include<bits/stdc++.h> using namespace std; int ask(int l, int r) { if(l>=r) return -1; cout<<"? "<<l<<" "<<r<<endl; int x; cin>>x; return x; } signed main() { // ios_base::sync_with_stdio(0); // cin.tie(0); int n; cin>>n; int smax=ask(1,n); int l,r; if(smax==n||ask(1,smax)==smax) { l=1; r=smax; while(l<r-1) { int m=(l+r)/2; if(ask(m,smax)==smax) { l=m; } else r=m; } cout<<"! "<<l<<endl; } else { l=smax, r=n; while(l<r-1) { int m=(l+r)/2; if(ask(smax,m)==smax) { r=m; } else l=m; } cout<<"! "<<r<<endl; } }
#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...