Submission #757821

# Submission time Handle Problem Language Result Execution time Memory
757821 2023-06-13T19:04:30 Z taher Mađioničar (COI22_madionicar) C++17
100 / 100
1952 ms 444 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  auto Ask = [&](int l, int r) {
    ++l, ++r;
    cout << "? " << l << " " << r << endl;
    int ret;
    cin >> ret;
    return ret;
  };
  int cur = 1;
  int res = 1;

  auto SolveOdd = [&](int it) {
    int lowOdd = it - cur;
    int highOdd = it + cur;
    bool foundOdd = false;
    while (lowOdd >= 0 && highOdd < n && Ask(lowOdd, highOdd) == 1) {
      foundOdd = true;
      lowOdd -= 1;
      highOdd += 1;
      cur += 1;
    }
    if (foundOdd) {
      cur -= 1;
      res = max(res, cur * 2 + 1);
      cur += 1;
    }
    return ;
  };

  auto SolveEven = [&](int it) {
    bool foundEven = false;
    int lowEven = it - cur + 1;
    int highEven = it + cur;
    while (lowEven >= 0 && highEven < n && Ask(lowEven, highEven) == 1) {
      foundEven = true;
      lowEven -= 1;
      highEven += 1;
      cur += 1;
    }
    if (foundEven) {
      cur -= 1;
      res = max(res, cur * 2);
      cur += 1;
    }    
  };

  for (int i = 0; i < n; i++) {
    SolveOdd(i);
  }
  for (int i = 0; i < n; i++) {
    SolveEven(i);
  }
  cout << "! " << res << endl;
  return 0; 
}
# Verdict Execution time Memory Grader output
1 Correct 148 ms 316 KB Output is correct
2 Correct 132 ms 308 KB Output is correct
3 Correct 136 ms 208 KB Output is correct
4 Correct 125 ms 208 KB Output is correct
5 Correct 129 ms 208 KB Output is correct
6 Correct 141 ms 208 KB Output is correct
7 Correct 72 ms 208 KB Output is correct
8 Correct 60 ms 208 KB Output is correct
9 Correct 110 ms 208 KB Output is correct
10 Correct 108 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 148 ms 316 KB Output is correct
2 Correct 132 ms 308 KB Output is correct
3 Correct 136 ms 208 KB Output is correct
4 Correct 125 ms 208 KB Output is correct
5 Correct 129 ms 208 KB Output is correct
6 Correct 141 ms 208 KB Output is correct
7 Correct 72 ms 208 KB Output is correct
8 Correct 60 ms 208 KB Output is correct
9 Correct 110 ms 208 KB Output is correct
10 Correct 108 ms 208 KB Output is correct
11 Correct 917 ms 312 KB Output is correct
12 Correct 1117 ms 208 KB Output is correct
13 Correct 1168 ms 256 KB Output is correct
14 Correct 555 ms 312 KB Output is correct
15 Correct 1077 ms 208 KB Output is correct
16 Correct 576 ms 208 KB Output is correct
17 Correct 513 ms 208 KB Output is correct
18 Correct 1024 ms 208 KB Output is correct
19 Correct 487 ms 208 KB Output is correct
20 Correct 1006 ms 208 KB Output is correct
21 Correct 976 ms 208 KB Output is correct
22 Correct 1081 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1442 ms 208 KB Output is correct
2 Correct 348 ms 208 KB Output is correct
3 Correct 1650 ms 308 KB Output is correct
4 Correct 1097 ms 208 KB Output is correct
5 Correct 961 ms 208 KB Output is correct
6 Correct 1881 ms 208 KB Output is correct
7 Correct 904 ms 444 KB Output is correct
8 Correct 1455 ms 208 KB Output is correct
9 Correct 1268 ms 208 KB Output is correct
10 Correct 1184 ms 312 KB Output is correct
11 Correct 795 ms 208 KB Output is correct
12 Correct 644 ms 372 KB Output is correct
13 Correct 1751 ms 208 KB Output is correct
14 Correct 1952 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 148 ms 316 KB Output is correct
2 Correct 132 ms 308 KB Output is correct
3 Correct 136 ms 208 KB Output is correct
4 Correct 125 ms 208 KB Output is correct
5 Correct 129 ms 208 KB Output is correct
6 Correct 141 ms 208 KB Output is correct
7 Correct 72 ms 208 KB Output is correct
8 Correct 60 ms 208 KB Output is correct
9 Correct 110 ms 208 KB Output is correct
10 Correct 108 ms 208 KB Output is correct
11 Correct 917 ms 312 KB Output is correct
12 Correct 1117 ms 208 KB Output is correct
13 Correct 1168 ms 256 KB Output is correct
14 Correct 555 ms 312 KB Output is correct
15 Correct 1077 ms 208 KB Output is correct
16 Correct 576 ms 208 KB Output is correct
17 Correct 513 ms 208 KB Output is correct
18 Correct 1024 ms 208 KB Output is correct
19 Correct 487 ms 208 KB Output is correct
20 Correct 1006 ms 208 KB Output is correct
21 Correct 976 ms 208 KB Output is correct
22 Correct 1081 ms 208 KB Output is correct
23 Correct 1442 ms 208 KB Output is correct
24 Correct 348 ms 208 KB Output is correct
25 Correct 1650 ms 308 KB Output is correct
26 Correct 1097 ms 208 KB Output is correct
27 Correct 961 ms 208 KB Output is correct
28 Correct 1881 ms 208 KB Output is correct
29 Correct 904 ms 444 KB Output is correct
30 Correct 1455 ms 208 KB Output is correct
31 Correct 1268 ms 208 KB Output is correct
32 Correct 1184 ms 312 KB Output is correct
33 Correct 795 ms 208 KB Output is correct
34 Correct 644 ms 372 KB Output is correct
35 Correct 1751 ms 208 KB Output is correct
36 Correct 1952 ms 300 KB Output is correct
37 Correct 1597 ms 208 KB Output is correct
38 Correct 1688 ms 208 KB Output is correct
39 Correct 1602 ms 208 KB Output is correct
40 Correct 1168 ms 208 KB Output is correct
41 Correct 1417 ms 208 KB Output is correct
42 Correct 709 ms 208 KB Output is correct
43 Correct 799 ms 208 KB Output is correct
44 Correct 1601 ms 208 KB Output is correct
45 Correct 858 ms 312 KB Output is correct
46 Correct 1524 ms 208 KB Output is correct
47 Correct 1600 ms 312 KB Output is correct
48 Correct 1581 ms 208 KB Output is correct
49 Correct 759 ms 208 KB Output is correct
50 Correct 738 ms 208 KB Output is correct
51 Correct 1739 ms 208 KB Output is correct
52 Correct 1512 ms 208 KB Output is correct