Submission #1128996

#TimeUsernameProblemLanguageResultExecution timeMemory
1128996gygMađioničar (COI22_madionicar)C++20
100 / 100
951 ms412 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n; bool chck(int i, int sz) { int l = (sz % 2 == 1) ? i - sz / 2 : i - sz / 2 + 1, r = i + sz / 2; if (min(l, r) < 1 || max(l, r) > n) return false; cout << "? " << l << " " << r << endl; bool ans; cin >> ans; return ans; } void cmp() { // Start sz at 2, even first int sz = 1, ans = 0; for (int i = 1; i <= n; i++) { while (true) { if (!chck(i, sz)) break; ans = sz, sz += 2; } } sz = ans + 1; for (int i = 1; i <= n; i++) { while (true) { if (!chck(i, sz)) break; ans = sz, sz += 2; } } cout << "! " << ans << endl; exit(0); } signed main() { cin >> n; cmp(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...