Submission #1114538

#TimeUsernameProblemLanguageResultExecution timeMemory
1114538SalihSahinMađioničar (COI22_madionicar)C++14
100 / 100
3812 ms336 KiB
#include <bits/stdc++.h> #define pb push_back #define int long long using namespace std; const int inf = 1e15 + 10; const int N = 3e5 + 5; bool query(int l, int r){ cout<<"? "<<l<<" "<<r<<"\n"; cout.flush(); bool pal; cin>>pal; return pal; } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin>>n; int oddmx = 1, evenmx = 0; for(int i = 1; i <= n; i++){ int st = oddmx + 2; for(int len = st; len <= n; len += 2){ int l = i - (len - 1)/2, r = i + (len - 1)/2; if(l < 1 || r > n) break; bool pal = query(l, r); if(!pal) break; oddmx = len; } } for(int i = 1; i <= n; i++){ int st = max(oddmx + 1, evenmx + 2); for(int len = st; len <= n; len += 2){ int l = i - len/2 + 1, r = i + len/2; if(l < 1 || r > n) break; bool pal = query(l, r); if(!pal) break; evenmx = len; } } int ans = max(oddmx, evenmx); 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...