Submission #747085

# Submission time Handle Problem Language Result Execution time Memory
747085 2023-05-23T15:25:43 Z MilosMilutinovic Mađioničar (COI22_madionicar) C++14
100 / 100
1847 ms 208 KB
/**
 *    author:  wxhtzdy
 *    created: 05.07.2022 14:44:38
**/
#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) {
    cout << "? " << l + 1 << " " << r + 1 << endl;
    int x;
    cin >> x;
    return x; 
  };
  int ans = 1;
  for (int i = 1; i < n; i++) {
    while (true) {
      int l = i - (ans + 1) / 2;
      int r = i + (ans + 1) / 2;
      if (l < 0 || r >= n || !Ask(l, r)) {
        break;
      }
      ans = r - l + 1;
    }
  }
  for (int i = 0; i + 1 < n; i++) {
    while (true) {
      int l = i - (ans % 2 == 1 ? (ans - 1) / 2 : ans / 2);
      int r = i + 1 + (ans % 2 == 1 ? (ans - 1) / 2 : ans / 2);
      if (l < 0 || r >= n || !Ask(l, r)) {
        break;
      }
      ans = r - l + 1;
    }
  }
  cout << "! " << ans << endl;                  
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 121 ms 208 KB Output is correct
2 Correct 121 ms 208 KB Output is correct
3 Correct 124 ms 208 KB Output is correct
4 Correct 135 ms 208 KB Output is correct
5 Correct 129 ms 208 KB Output is correct
6 Correct 140 ms 208 KB Output is correct
7 Correct 60 ms 208 KB Output is correct
8 Correct 43 ms 208 KB Output is correct
9 Correct 107 ms 208 KB Output is correct
10 Correct 148 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 121 ms 208 KB Output is correct
2 Correct 121 ms 208 KB Output is correct
3 Correct 124 ms 208 KB Output is correct
4 Correct 135 ms 208 KB Output is correct
5 Correct 129 ms 208 KB Output is correct
6 Correct 140 ms 208 KB Output is correct
7 Correct 60 ms 208 KB Output is correct
8 Correct 43 ms 208 KB Output is correct
9 Correct 107 ms 208 KB Output is correct
10 Correct 148 ms 208 KB Output is correct
11 Correct 731 ms 208 KB Output is correct
12 Correct 982 ms 208 KB Output is correct
13 Correct 1194 ms 208 KB Output is correct
14 Correct 847 ms 208 KB Output is correct
15 Correct 1079 ms 208 KB Output is correct
16 Correct 273 ms 208 KB Output is correct
17 Correct 523 ms 208 KB Output is correct
18 Correct 789 ms 208 KB Output is correct
19 Correct 487 ms 208 KB Output is correct
20 Correct 969 ms 208 KB Output is correct
21 Correct 927 ms 208 KB Output is correct
22 Correct 992 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1529 ms 208 KB Output is correct
2 Correct 267 ms 208 KB Output is correct
3 Correct 1694 ms 208 KB Output is correct
4 Correct 974 ms 208 KB Output is correct
5 Correct 886 ms 208 KB Output is correct
6 Correct 1587 ms 208 KB Output is correct
7 Correct 867 ms 208 KB Output is correct
8 Correct 1638 ms 208 KB Output is correct
9 Correct 1755 ms 208 KB Output is correct
10 Correct 1804 ms 208 KB Output is correct
11 Correct 733 ms 208 KB Output is correct
12 Correct 810 ms 208 KB Output is correct
13 Correct 1622 ms 208 KB Output is correct
14 Correct 1443 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 121 ms 208 KB Output is correct
2 Correct 121 ms 208 KB Output is correct
3 Correct 124 ms 208 KB Output is correct
4 Correct 135 ms 208 KB Output is correct
5 Correct 129 ms 208 KB Output is correct
6 Correct 140 ms 208 KB Output is correct
7 Correct 60 ms 208 KB Output is correct
8 Correct 43 ms 208 KB Output is correct
9 Correct 107 ms 208 KB Output is correct
10 Correct 148 ms 208 KB Output is correct
11 Correct 731 ms 208 KB Output is correct
12 Correct 982 ms 208 KB Output is correct
13 Correct 1194 ms 208 KB Output is correct
14 Correct 847 ms 208 KB Output is correct
15 Correct 1079 ms 208 KB Output is correct
16 Correct 273 ms 208 KB Output is correct
17 Correct 523 ms 208 KB Output is correct
18 Correct 789 ms 208 KB Output is correct
19 Correct 487 ms 208 KB Output is correct
20 Correct 969 ms 208 KB Output is correct
21 Correct 927 ms 208 KB Output is correct
22 Correct 992 ms 208 KB Output is correct
23 Correct 1529 ms 208 KB Output is correct
24 Correct 267 ms 208 KB Output is correct
25 Correct 1694 ms 208 KB Output is correct
26 Correct 974 ms 208 KB Output is correct
27 Correct 886 ms 208 KB Output is correct
28 Correct 1587 ms 208 KB Output is correct
29 Correct 867 ms 208 KB Output is correct
30 Correct 1638 ms 208 KB Output is correct
31 Correct 1755 ms 208 KB Output is correct
32 Correct 1804 ms 208 KB Output is correct
33 Correct 733 ms 208 KB Output is correct
34 Correct 810 ms 208 KB Output is correct
35 Correct 1622 ms 208 KB Output is correct
36 Correct 1443 ms 208 KB Output is correct
37 Correct 1793 ms 208 KB Output is correct
38 Correct 1819 ms 208 KB Output is correct
39 Correct 1619 ms 208 KB Output is correct
40 Correct 983 ms 208 KB Output is correct
41 Correct 1464 ms 208 KB Output is correct
42 Correct 935 ms 208 KB Output is correct
43 Correct 621 ms 208 KB Output is correct
44 Correct 1441 ms 208 KB Output is correct
45 Correct 873 ms 208 KB Output is correct
46 Correct 1198 ms 208 KB Output is correct
47 Correct 1741 ms 208 KB Output is correct
48 Correct 1847 ms 208 KB Output is correct
49 Correct 1032 ms 208 KB Output is correct
50 Correct 971 ms 208 KB Output is correct
51 Correct 1679 ms 208 KB Output is correct
52 Correct 1568 ms 208 KB Output is correct