Submission #1019676

# Submission time Handle Problem Language Result Execution time Memory
1019676 2024-07-11T07:18:47 Z thangdz2k7 Mađioničar (COI22_madionicar) C++17
100 / 100
1227 ms 596 KB
#include <bits/stdc++.h>

using namespace std;

bool ask(int l, int r){
    cout << "? " << l << ' ' << r;
    cout << endl;
    int t; cin >> t;
    return t;
}

void answer(int L){
    cout << "! " << L;
    cout << endl;
}

void solve(){
    int n; cin >> n;
    int ans = 1;
    for (int i = 1; i <= n; ++ i){
        while (i - ans >= 1 && i + ans <= n && ask(i - ans, i + ans)) ++ ans;
    }
    int res = 2 * ans - 1;
    for (int i = 1; i <= n; ++ i){
        while (i - ans + 1 >= 1 && i + ans <= n && ask(i - ans + 1, i + ans)) ++ ans, res = max(res, 2 * ans - 2);
    }
    answer(res);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 71 ms 344 KB Output is correct
2 Correct 86 ms 344 KB Output is correct
3 Correct 75 ms 344 KB Output is correct
4 Correct 84 ms 344 KB Output is correct
5 Correct 74 ms 344 KB Output is correct
6 Correct 70 ms 344 KB Output is correct
7 Correct 25 ms 344 KB Output is correct
8 Correct 35 ms 340 KB Output is correct
9 Correct 65 ms 344 KB Output is correct
10 Correct 72 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 344 KB Output is correct
2 Correct 86 ms 344 KB Output is correct
3 Correct 75 ms 344 KB Output is correct
4 Correct 84 ms 344 KB Output is correct
5 Correct 74 ms 344 KB Output is correct
6 Correct 70 ms 344 KB Output is correct
7 Correct 25 ms 344 KB Output is correct
8 Correct 35 ms 340 KB Output is correct
9 Correct 65 ms 344 KB Output is correct
10 Correct 72 ms 344 KB Output is correct
11 Correct 769 ms 344 KB Output is correct
12 Correct 739 ms 344 KB Output is correct
13 Correct 762 ms 344 KB Output is correct
14 Correct 685 ms 344 KB Output is correct
15 Correct 718 ms 344 KB Output is correct
16 Correct 412 ms 344 KB Output is correct
17 Correct 390 ms 344 KB Output is correct
18 Correct 751 ms 596 KB Output is correct
19 Correct 359 ms 344 KB Output is correct
20 Correct 755 ms 344 KB Output is correct
21 Correct 759 ms 344 KB Output is correct
22 Correct 768 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1203 ms 344 KB Output is correct
2 Correct 306 ms 344 KB Output is correct
3 Correct 1084 ms 344 KB Output is correct
4 Correct 754 ms 344 KB Output is correct
5 Correct 560 ms 344 KB Output is correct
6 Correct 1103 ms 344 KB Output is correct
7 Correct 607 ms 344 KB Output is correct
8 Correct 1102 ms 344 KB Output is correct
9 Correct 1128 ms 344 KB Output is correct
10 Correct 1008 ms 344 KB Output is correct
11 Correct 502 ms 344 KB Output is correct
12 Correct 524 ms 344 KB Output is correct
13 Correct 1103 ms 344 KB Output is correct
14 Correct 1150 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 344 KB Output is correct
2 Correct 86 ms 344 KB Output is correct
3 Correct 75 ms 344 KB Output is correct
4 Correct 84 ms 344 KB Output is correct
5 Correct 74 ms 344 KB Output is correct
6 Correct 70 ms 344 KB Output is correct
7 Correct 25 ms 344 KB Output is correct
8 Correct 35 ms 340 KB Output is correct
9 Correct 65 ms 344 KB Output is correct
10 Correct 72 ms 344 KB Output is correct
11 Correct 769 ms 344 KB Output is correct
12 Correct 739 ms 344 KB Output is correct
13 Correct 762 ms 344 KB Output is correct
14 Correct 685 ms 344 KB Output is correct
15 Correct 718 ms 344 KB Output is correct
16 Correct 412 ms 344 KB Output is correct
17 Correct 390 ms 344 KB Output is correct
18 Correct 751 ms 596 KB Output is correct
19 Correct 359 ms 344 KB Output is correct
20 Correct 755 ms 344 KB Output is correct
21 Correct 759 ms 344 KB Output is correct
22 Correct 768 ms 344 KB Output is correct
23 Correct 1203 ms 344 KB Output is correct
24 Correct 306 ms 344 KB Output is correct
25 Correct 1084 ms 344 KB Output is correct
26 Correct 754 ms 344 KB Output is correct
27 Correct 560 ms 344 KB Output is correct
28 Correct 1103 ms 344 KB Output is correct
29 Correct 607 ms 344 KB Output is correct
30 Correct 1102 ms 344 KB Output is correct
31 Correct 1128 ms 344 KB Output is correct
32 Correct 1008 ms 344 KB Output is correct
33 Correct 502 ms 344 KB Output is correct
34 Correct 524 ms 344 KB Output is correct
35 Correct 1103 ms 344 KB Output is correct
36 Correct 1150 ms 344 KB Output is correct
37 Correct 1142 ms 344 KB Output is correct
38 Correct 1171 ms 344 KB Output is correct
39 Correct 1123 ms 344 KB Output is correct
40 Correct 1060 ms 344 KB Output is correct
41 Correct 1113 ms 344 KB Output is correct
42 Correct 762 ms 344 KB Output is correct
43 Correct 576 ms 344 KB Output is correct
44 Correct 1100 ms 344 KB Output is correct
45 Correct 559 ms 344 KB Output is correct
46 Correct 1147 ms 344 KB Output is correct
47 Correct 1227 ms 596 KB Output is correct
48 Correct 1168 ms 344 KB Output is correct
49 Correct 574 ms 344 KB Output is correct
50 Correct 571 ms 344 KB Output is correct
51 Correct 1214 ms 344 KB Output is correct
52 Correct 1216 ms 344 KB Output is correct