Submission #1171803

#TimeUsernameProblemLanguageResultExecution timeMemory
1171803peterandvoiMađioničar (COI22_madionicar)C++20
100 / 100
490 ms432 KiB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "C:\debug.h"
#else
#define debug(...) 42
#endif

bool ask(int l, int r) {
  cout << "? " << l + 1 << " " << r + 1 << endl;
  bool x; cin >> x; return x;
}

int main() {
  ios::sync_with_stdio(false); 
  cin.tie(nullptr);
  int n; cin >> n;
  int odd = 1, even = 0;
  for (int i = 0; i < n; ++i) {
    while (i - even >= 0 && i + 1 + even < n && ask(i - even, i + 1 + even)) ++even;
    while (i - odd >= 0 && i + odd < n && ask(i - odd, i + odd)) ++odd;
  }
  cout << "! " << max(2 * even, 2 * odd - 1);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...