Submission #1005716

#TimeUsernameProblemLanguageResultExecution timeMemory
1005716SuPythonyMađioničar (COI22_madionicar)C++17
100 / 100
1215 ms344 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++) { if (ans1==n) break; 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) { while (true) { ans1=max(ans1,r-l+1); 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++) { if (ans1==n||ans2==n) break; 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) { while (true) { ans2=max(ans2,r-l+1); 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...