Submission #1005714

#TimeUsernameProblemLanguageResultExecution timeMemory
1005714SuPythonyMađioničar (COI22_madionicar)C++17
0 / 100
1152 ms408 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin>>n; int ans1=1; for (int i=1; i<=n; i++) { int l=i-(ans1+2)/2,r=i+(ans1+2)/2; if (l<1||r>n) continue; cout<<"? "<<l<<" "<<r<<endl; cout.flush(); int a; cin>>a; if (a) { ans1=max(ans1,r-l+1); while (true) { l--; r++; if (l<1||r>n) break; cout<<"? "<<l<<" "<<r<<endl; cout.flush(); cin>>a; if (!a) break; } } } int ans2=0; for (int i=1; i<=n; i++) { int l=i-(ans2+2)/2+1,r=i+(ans2+2)/2; if (l<1||r>n) continue; cout<<"? "<<l<<" "<<r<<endl; cout.flush(); int a; cin>>a; if (a) { ans2=max(ans2,r-l+1); while (true) { l--; r++; if (l<1||r>n) break; cout<<"? "<<l<<" "<<r<<endl; cout.flush(); cin>>a; if (!a) break; } } } cout<<"! "<<max(ans1,ans2)<<endl; cout.flush(); 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...