Submission #1027045

#TimeUsernameProblemLanguageResultExecution timeMemory
1027045VMaksimoski008Mađioničar (COI22_madionicar)C++17
100 / 100
1230 ms344 KiB
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; int query(int l, int r) { cout << "? " << l << " " << r << endl; int x; cin >> x; return x; } int get1(int p, int d, int n) { if(p - d < 1 || p + d > n) return 0; return query(p - d, p + d); } int get2(int p, int d, int n) { if(p - d + 1 < 1 || p + d > n) return 0; return query(p - d + 1, p + d); } int main() { int n, ans1=0, ans2=0; cin >> n; for(int i=1; i<=n; i++) while(get1(i, ans1+1, n)) ans1++; for(int i=1; i+1<=n; i++) while(get2(i, ans2+1, n)) ans2++; cout << "! " << max(2 * ans1 + 1, 2 * ans2) << endl; 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...