답안 #963907

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963907 2024-04-16T02:47:21 Z becaido Mađioničar (COI22_madionicar) C++17
63 / 100
1016 ms 2280 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;

#ifdef WAIMAI
#define debug(HEHE...) cout << "[" << #HEHE << "] : ", dout(HEHE)
void dout() {cout << '\n';}
template<typename T, typename...U>
void dout(T t, U...u) {cout << t << (sizeof...(u) ? ", " : ""), dout(u...);}
#else
#define debug(...) 7122
#endif

#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second

const int SIZE = 2e5 + 5;

int n;
int z[SIZE];

int cnt;
int que(int l, int r) {
    if (l & 1) return 1;
    cnt++;
    if (cnt > 200000) {
        cout << "! " << *max_element(z + 1, z + n + 1) << '\n';
        exit(0);
    }
    int foo = 114514;
    l /= 2, r /= 2;
    cout << "? " << l << ' ' << r << endl;
    cin >> foo;
    return foo;
}

void solve() {
    cin >> n;
    n = 2 * n + 1;
    for (int i = 1, mid = 0, r = 0; i <= n; i++) {
        if (i <= r) {
            z[i] = min(z[2 * mid - i], r - i);
            if (i + z[i] < r) continue;
        }
        int len = min(i - 1, n - i);
        for (int j = z[i] + 1; j <= len; j++) {
            if (que(i - j, i + j) == 0) break;
            z[i]++;
        }
        if (i + z[i] > r) {
            mid = i;
            r = i + z[i];
        }
    }
    cout << "! " << *max_element(z + 1, z + n + 1) << '\n';
}

int main() {
    Waimai;
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 1248 KB Output is correct
2 Correct 73 ms 1252 KB Output is correct
3 Correct 73 ms 1128 KB Output is correct
4 Correct 69 ms 996 KB Output is correct
5 Correct 91 ms 988 KB Output is correct
6 Correct 65 ms 1248 KB Output is correct
7 Correct 68 ms 600 KB Output is correct
8 Correct 70 ms 1244 KB Output is correct
9 Correct 104 ms 744 KB Output is correct
10 Correct 76 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 1248 KB Output is correct
2 Correct 73 ms 1252 KB Output is correct
3 Correct 73 ms 1128 KB Output is correct
4 Correct 69 ms 996 KB Output is correct
5 Correct 91 ms 988 KB Output is correct
6 Correct 65 ms 1248 KB Output is correct
7 Correct 68 ms 600 KB Output is correct
8 Correct 70 ms 1244 KB Output is correct
9 Correct 104 ms 744 KB Output is correct
10 Correct 76 ms 1116 KB Output is correct
11 Correct 599 ms 1588 KB Output is correct
12 Correct 658 ms 1664 KB Output is correct
13 Correct 669 ms 1776 KB Output is correct
14 Correct 578 ms 1388 KB Output is correct
15 Correct 638 ms 1936 KB Output is correct
16 Correct 613 ms 1180 KB Output is correct
17 Correct 609 ms 1448 KB Output is correct
18 Correct 577 ms 2036 KB Output is correct
19 Correct 975 ms 1716 KB Output is correct
20 Correct 602 ms 1952 KB Output is correct
21 Correct 551 ms 2124 KB Output is correct
22 Correct 662 ms 1652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 869 ms 1948 KB Output is correct
2 Correct 509 ms 1620 KB Output is correct
3 Correct 823 ms 2024 KB Output is correct
4 Correct 1000 ms 1612 KB Output is correct
5 Correct 945 ms 1836 KB Output is correct
6 Correct 756 ms 1912 KB Output is correct
7 Correct 1016 ms 1428 KB Output is correct
8 Correct 842 ms 2280 KB Output is correct
9 Correct 787 ms 2108 KB Output is correct
10 Correct 797 ms 2196 KB Output is correct
11 Correct 962 ms 1540 KB Output is correct
12 Correct 990 ms 1844 KB Output is correct
13 Correct 817 ms 2104 KB Output is correct
14 Correct 814 ms 1924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 1248 KB Output is correct
2 Correct 73 ms 1252 KB Output is correct
3 Correct 73 ms 1128 KB Output is correct
4 Correct 69 ms 996 KB Output is correct
5 Correct 91 ms 988 KB Output is correct
6 Correct 65 ms 1248 KB Output is correct
7 Correct 68 ms 600 KB Output is correct
8 Correct 70 ms 1244 KB Output is correct
9 Correct 104 ms 744 KB Output is correct
10 Correct 76 ms 1116 KB Output is correct
11 Correct 599 ms 1588 KB Output is correct
12 Correct 658 ms 1664 KB Output is correct
13 Correct 669 ms 1776 KB Output is correct
14 Correct 578 ms 1388 KB Output is correct
15 Correct 638 ms 1936 KB Output is correct
16 Correct 613 ms 1180 KB Output is correct
17 Correct 609 ms 1448 KB Output is correct
18 Correct 577 ms 2036 KB Output is correct
19 Correct 975 ms 1716 KB Output is correct
20 Correct 602 ms 1952 KB Output is correct
21 Correct 551 ms 2124 KB Output is correct
22 Correct 662 ms 1652 KB Output is correct
23 Correct 869 ms 1948 KB Output is correct
24 Correct 509 ms 1620 KB Output is correct
25 Correct 823 ms 2024 KB Output is correct
26 Correct 1000 ms 1612 KB Output is correct
27 Correct 945 ms 1836 KB Output is correct
28 Correct 756 ms 1912 KB Output is correct
29 Correct 1016 ms 1428 KB Output is correct
30 Correct 842 ms 2280 KB Output is correct
31 Correct 787 ms 2108 KB Output is correct
32 Correct 797 ms 2196 KB Output is correct
33 Correct 962 ms 1540 KB Output is correct
34 Correct 990 ms 1844 KB Output is correct
35 Correct 817 ms 2104 KB Output is correct
36 Correct 814 ms 1924 KB Output is correct
37 Correct 810 ms 1932 KB Output is correct
38 Incorrect 994 ms 2200 KB too many queries
39 Halted 0 ms 0 KB -