Submission #1019676

#TimeUsernameProblemLanguageResultExecution timeMemory
1019676thangdz2k7Mađioničar (COI22_madionicar)C++17
100 / 100
1227 ms596 KiB
#include <bits/stdc++.h> using namespace std; bool ask(int l, int r){ cout << "? " << l << ' ' << r; cout << endl; int t; cin >> t; return t; } void answer(int L){ cout << "! " << L; cout << endl; } void solve(){ int n; cin >> n; int ans = 1; for (int i = 1; i <= n; ++ i){ while (i - ans >= 1 && i + ans <= n && ask(i - ans, i + ans)) ++ ans; } int res = 2 * ans - 1; for (int i = 1; i <= n; ++ i){ while (i - ans + 1 >= 1 && i + ans <= n && ask(i - ans + 1, i + ans)) ++ ans, res = max(res, 2 * ans - 2); } answer(res); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); solve(); 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...