Submission #1005713

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