Submission #777738

# Submission time Handle Problem Language Result Execution time Memory
777738 2023-07-09T14:41:17 Z dxz05 Mađioničar (COI22_madionicar) C++17
100 / 100
1543 ms 256 KB
//#pragma GCC optimize("Ofast,O3,unroll-loops")
//#pragma GCC target("avx,avx2")

#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bpc(x) __builtin_popcount(x)
#define bpcll(x) __builtin_popcountll(x)
#define MP make_pair
//#define endl '\n'

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

typedef long long ll;
const int MOD = 1e9 + 7;
const int N = 1e5 + 3e2;

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

void solve(){
    int n;
    cin >> n;

    int odd = 3;
    for (int i = 0; i < n; i++){
        while (true){
            int l = i - odd / 2, r = i + odd / 2;
            if (0 <= l && r < n && ask(l, r)){
                odd += 2;
            } else {
                break;
            }
        }
    }

    int even = 2;
    for (int i = 0; i < n; i++){
        while (true){
            int l = i - even / 2 + 1, r = i + even / 2;
            if (0 <= l && r < n && ask(l, r)){
                even += 2;
            } else {
                break;
            }
        }
    }

    cout << "! " << max(odd, even) - 2 << endl;

}

int main(){
    clock_t startTime = clock();
    ios_base::sync_with_stdio(false);

#ifdef LOCAL
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif

    int test_cases = 1;
//    cin >> test_cases;

    for (int test = 1; test <= test_cases; test++){
        // cout << (solve() ? "YES" : "NO") << endl;
        solve();
    }

#ifdef LOCAL
    cerr << "Time: " << int((double) (clock() - startTime) / CLOCKS_PER_SEC * 1000) << " ms" << endl;
#endif

    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:61:13: warning: unused variable 'startTime' [-Wunused-variable]
   61 |     clock_t startTime = clock();
      |             ^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 91 ms 208 KB Output is correct
2 Correct 82 ms 208 KB Output is correct
3 Correct 63 ms 208 KB Output is correct
4 Correct 89 ms 208 KB Output is correct
5 Correct 112 ms 208 KB Output is correct
6 Correct 126 ms 256 KB Output is correct
7 Correct 129 ms 208 KB Output is correct
8 Correct 137 ms 208 KB Output is correct
9 Correct 43 ms 208 KB Output is correct
10 Correct 104 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 208 KB Output is correct
2 Correct 82 ms 208 KB Output is correct
3 Correct 63 ms 208 KB Output is correct
4 Correct 89 ms 208 KB Output is correct
5 Correct 112 ms 208 KB Output is correct
6 Correct 126 ms 256 KB Output is correct
7 Correct 129 ms 208 KB Output is correct
8 Correct 137 ms 208 KB Output is correct
9 Correct 43 ms 208 KB Output is correct
10 Correct 104 ms 208 KB Output is correct
11 Correct 804 ms 208 KB Output is correct
12 Correct 790 ms 208 KB Output is correct
13 Correct 715 ms 208 KB Output is correct
14 Correct 653 ms 208 KB Output is correct
15 Correct 960 ms 208 KB Output is correct
16 Correct 812 ms 208 KB Output is correct
17 Correct 741 ms 208 KB Output is correct
18 Correct 642 ms 208 KB Output is correct
19 Correct 697 ms 208 KB Output is correct
20 Correct 794 ms 208 KB Output is correct
21 Correct 768 ms 208 KB Output is correct
22 Correct 858 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1305 ms 208 KB Output is correct
2 Correct 1107 ms 208 KB Output is correct
3 Correct 1423 ms 208 KB Output is correct
4 Correct 1301 ms 208 KB Output is correct
5 Correct 1385 ms 208 KB Output is correct
6 Correct 1246 ms 208 KB Output is correct
7 Correct 1455 ms 208 KB Output is correct
8 Correct 1016 ms 208 KB Output is correct
9 Correct 1179 ms 208 KB Output is correct
10 Correct 1406 ms 208 KB Output is correct
11 Correct 1398 ms 208 KB Output is correct
12 Correct 1122 ms 208 KB Output is correct
13 Correct 1310 ms 208 KB Output is correct
14 Correct 1302 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 208 KB Output is correct
2 Correct 82 ms 208 KB Output is correct
3 Correct 63 ms 208 KB Output is correct
4 Correct 89 ms 208 KB Output is correct
5 Correct 112 ms 208 KB Output is correct
6 Correct 126 ms 256 KB Output is correct
7 Correct 129 ms 208 KB Output is correct
8 Correct 137 ms 208 KB Output is correct
9 Correct 43 ms 208 KB Output is correct
10 Correct 104 ms 208 KB Output is correct
11 Correct 804 ms 208 KB Output is correct
12 Correct 790 ms 208 KB Output is correct
13 Correct 715 ms 208 KB Output is correct
14 Correct 653 ms 208 KB Output is correct
15 Correct 960 ms 208 KB Output is correct
16 Correct 812 ms 208 KB Output is correct
17 Correct 741 ms 208 KB Output is correct
18 Correct 642 ms 208 KB Output is correct
19 Correct 697 ms 208 KB Output is correct
20 Correct 794 ms 208 KB Output is correct
21 Correct 768 ms 208 KB Output is correct
22 Correct 858 ms 208 KB Output is correct
23 Correct 1305 ms 208 KB Output is correct
24 Correct 1107 ms 208 KB Output is correct
25 Correct 1423 ms 208 KB Output is correct
26 Correct 1301 ms 208 KB Output is correct
27 Correct 1385 ms 208 KB Output is correct
28 Correct 1246 ms 208 KB Output is correct
29 Correct 1455 ms 208 KB Output is correct
30 Correct 1016 ms 208 KB Output is correct
31 Correct 1179 ms 208 KB Output is correct
32 Correct 1406 ms 208 KB Output is correct
33 Correct 1398 ms 208 KB Output is correct
34 Correct 1122 ms 208 KB Output is correct
35 Correct 1310 ms 208 KB Output is correct
36 Correct 1302 ms 208 KB Output is correct
37 Correct 1236 ms 208 KB Output is correct
38 Correct 1152 ms 208 KB Output is correct
39 Correct 1390 ms 208 KB Output is correct
40 Correct 1543 ms 208 KB Output is correct
41 Correct 1341 ms 208 KB Output is correct
42 Correct 1347 ms 208 KB Output is correct
43 Correct 1090 ms 208 KB Output is correct
44 Correct 1049 ms 208 KB Output is correct
45 Correct 1389 ms 208 KB Output is correct
46 Correct 1160 ms 208 KB Output is correct
47 Correct 994 ms 220 KB Output is correct
48 Correct 1407 ms 208 KB Output is correct
49 Correct 1221 ms 208 KB Output is correct
50 Correct 1201 ms 208 KB Output is correct
51 Correct 983 ms 208 KB Output is correct
52 Correct 1012 ms 208 KB Output is correct