Submission #836841

# Submission time Handle Problem Language Result Execution time Memory
836841 2023-08-24T16:15:05 Z tengiz05 Radio Towers (IOI22_towers) C++17
56 / 100
889 ms 14480 KB
#include "towers.h"

#include <bits/stdc++.h>
using namespace std;

vector<int> h;
int n;
void init(int N, vector<int> H) {
    n = N;
    h = H;
}

bool processed = false;
vector<int> nxt, dow;
vector<vector<int>> jump;
int max_towers(int l, int r, int D) {
    if (!processed) {
        processed = true;
        deque<pair<int, int>> st;
        nxt.assign(n + 1, n);
        dow.assign(n + 1, n);
        for (int i = n - 1; i >= 0; i--) {
            while (!st.empty() && h[st.front().second] <= h[i]) st.pop_front();
            st.push_front({h[i], i});
            auto p = lower_bound(st.begin(), st.end(), pair{h[i] + D, -1});
            if (p != st.end()) {
                nxt[i] = p->second;
            }
        }
        for (int i = n - 2; i >= 0; i--) {
            nxt[i] = min(nxt[i], nxt[i + 1]);
        }
        st.clear();
        for (int i = n - 1; i >= 0; i--) {
            while (!st.empty() && h[st.back().second] >= h[i]) st.pop_back();
            st.push_back({h[i], i});
            auto p = lower_bound(st.begin(), st.end(), pair{h[i] - D + 1, -1});
            if (p != st.begin()) {
                p--;
                dow[i] = p->second;
            }
        }
        for (int i = n - 2; i >= 0; i--) {
            dow[i] = min(dow[i], dow[i + 1]);
        }
        jump.assign(n + 1, vector<int>(20, n));
        for (int i = 0; i < n; i++) {
            jump[i][0] = nxt[i];
            jump[i][1] = dow[nxt[i]];
        }
        for (int j = 2; j < 20; j++) {
            for (int i = 0; i < n; i++) {
                jump[i][j] = jump[jump[i][j - 1]][j - 1];
            }
        }
    }
    int p = l;
    int s = 0;
    for (int i = 19; i >= 1; i--) {
        if (jump[p][i] <= r) {
            p = jump[p][i];
            s += 1 << i;
        }
    }
    return s / 2 + 1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 292 ms 8164 KB 31st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 464 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 1 ms 464 KB Output is correct
17 Correct 1 ms 464 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 464 KB Output is correct
20 Correct 1 ms 464 KB Output is correct
21 Correct 1 ms 508 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 1 ms 464 KB Output is correct
24 Correct 1 ms 464 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 1 ms 464 KB Output is correct
28 Correct 1 ms 556 KB Output is correct
29 Correct 1 ms 464 KB Output is correct
30 Correct 1 ms 464 KB Output is correct
31 Correct 1 ms 464 KB Output is correct
32 Correct 1 ms 464 KB Output is correct
33 Correct 1 ms 464 KB Output is correct
34 Correct 1 ms 464 KB Output is correct
35 Correct 1 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 464 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 1 ms 464 KB Output is correct
17 Correct 1 ms 464 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 464 KB Output is correct
20 Correct 1 ms 464 KB Output is correct
21 Correct 1 ms 508 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 1 ms 464 KB Output is correct
24 Correct 1 ms 464 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 1 ms 464 KB Output is correct
28 Correct 1 ms 556 KB Output is correct
29 Correct 1 ms 464 KB Output is correct
30 Correct 1 ms 464 KB Output is correct
31 Correct 1 ms 464 KB Output is correct
32 Correct 1 ms 464 KB Output is correct
33 Correct 1 ms 464 KB Output is correct
34 Correct 1 ms 464 KB Output is correct
35 Correct 1 ms 464 KB Output is correct
36 Correct 21 ms 8880 KB Output is correct
37 Correct 30 ms 13596 KB Output is correct
38 Correct 31 ms 13512 KB Output is correct
39 Correct 27 ms 13508 KB Output is correct
40 Correct 28 ms 13520 KB Output is correct
41 Correct 36 ms 13552 KB Output is correct
42 Correct 26 ms 13504 KB Output is correct
43 Correct 39 ms 13836 KB Output is correct
44 Correct 31 ms 14364 KB Output is correct
45 Correct 31 ms 13608 KB Output is correct
46 Correct 40 ms 14028 KB Output is correct
47 Correct 29 ms 13504 KB Output is correct
48 Correct 32 ms 13588 KB Output is correct
49 Correct 29 ms 13580 KB Output is correct
50 Correct 32 ms 14412 KB Output is correct
51 Correct 34 ms 13616 KB Output is correct
52 Correct 29 ms 13588 KB Output is correct
53 Correct 29 ms 13480 KB Output is correct
54 Correct 28 ms 13604 KB Output is correct
55 Correct 32 ms 14336 KB Output is correct
56 Correct 32 ms 13620 KB Output is correct
57 Correct 36 ms 13088 KB Output is correct
58 Correct 33 ms 13584 KB Output is correct
59 Correct 35 ms 13596 KB Output is correct
60 Correct 30 ms 13588 KB Output is correct
61 Correct 28 ms 13600 KB Output is correct
62 Correct 29 ms 13588 KB Output is correct
63 Correct 33 ms 13508 KB Output is correct
64 Correct 29 ms 13512 KB Output is correct
65 Correct 30 ms 14480 KB Output is correct
66 Correct 30 ms 13608 KB Output is correct
67 Correct 30 ms 14272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 555 ms 13484 KB Output is correct
2 Correct 710 ms 13596 KB Output is correct
3 Correct 889 ms 13480 KB Output is correct
4 Correct 725 ms 13480 KB Output is correct
5 Correct 760 ms 13480 KB Output is correct
6 Correct 858 ms 13592 KB Output is correct
7 Correct 886 ms 13576 KB Output is correct
8 Correct 657 ms 13608 KB Output is correct
9 Correct 597 ms 14332 KB Output is correct
10 Correct 559 ms 13504 KB Output is correct
11 Correct 643 ms 13864 KB Output is correct
12 Correct 644 ms 13504 KB Output is correct
13 Correct 589 ms 14376 KB Output is correct
14 Correct 0 ms 208 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 1 ms 464 KB Output is correct
17 Correct 32 ms 13512 KB Output is correct
18 Correct 29 ms 13476 KB Output is correct
19 Correct 29 ms 13516 KB Output is correct
20 Correct 33 ms 14424 KB Output is correct
21 Correct 35 ms 13504 KB Output is correct
22 Correct 29 ms 13504 KB Output is correct
23 Correct 28 ms 13600 KB Output is correct
24 Correct 38 ms 13604 KB Output is correct
25 Correct 35 ms 14384 KB Output is correct
26 Correct 30 ms 13620 KB Output is correct
27 Correct 1 ms 464 KB Output is correct
28 Correct 1 ms 464 KB Output is correct
29 Correct 1 ms 464 KB Output is correct
30 Correct 1 ms 464 KB Output is correct
31 Correct 1 ms 464 KB Output is correct
32 Correct 1 ms 464 KB Output is correct
33 Correct 1 ms 464 KB Output is correct
34 Correct 1 ms 464 KB Output is correct
35 Correct 1 ms 464 KB Output is correct
36 Correct 1 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 161 ms 3408 KB 2nd lines differ - on the 1st token, expected: '7063', found: '7197'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 336 KB Output is correct
2 Correct 1 ms 464 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 464 KB Output is correct
5 Correct 1 ms 464 KB Output is correct
6 Correct 1 ms 592 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 464 KB Output is correct
14 Correct 1 ms 464 KB Output is correct
15 Correct 1 ms 464 KB Output is correct
16 Correct 1 ms 464 KB Output is correct
17 Correct 1 ms 464 KB Output is correct
18 Correct 1 ms 464 KB Output is correct
19 Correct 1 ms 464 KB Output is correct
20 Correct 1 ms 464 KB Output is correct
21 Correct 1 ms 508 KB Output is correct
22 Correct 1 ms 464 KB Output is correct
23 Correct 1 ms 464 KB Output is correct
24 Correct 1 ms 464 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 464 KB Output is correct
27 Correct 1 ms 464 KB Output is correct
28 Correct 1 ms 556 KB Output is correct
29 Correct 1 ms 464 KB Output is correct
30 Correct 1 ms 464 KB Output is correct
31 Correct 1 ms 464 KB Output is correct
32 Correct 1 ms 464 KB Output is correct
33 Correct 1 ms 464 KB Output is correct
34 Correct 1 ms 464 KB Output is correct
35 Correct 1 ms 464 KB Output is correct
36 Correct 21 ms 8880 KB Output is correct
37 Correct 30 ms 13596 KB Output is correct
38 Correct 31 ms 13512 KB Output is correct
39 Correct 27 ms 13508 KB Output is correct
40 Correct 28 ms 13520 KB Output is correct
41 Correct 36 ms 13552 KB Output is correct
42 Correct 26 ms 13504 KB Output is correct
43 Correct 39 ms 13836 KB Output is correct
44 Correct 31 ms 14364 KB Output is correct
45 Correct 31 ms 13608 KB Output is correct
46 Correct 40 ms 14028 KB Output is correct
47 Correct 29 ms 13504 KB Output is correct
48 Correct 32 ms 13588 KB Output is correct
49 Correct 29 ms 13580 KB Output is correct
50 Correct 32 ms 14412 KB Output is correct
51 Correct 34 ms 13616 KB Output is correct
52 Correct 29 ms 13588 KB Output is correct
53 Correct 29 ms 13480 KB Output is correct
54 Correct 28 ms 13604 KB Output is correct
55 Correct 32 ms 14336 KB Output is correct
56 Correct 32 ms 13620 KB Output is correct
57 Correct 36 ms 13088 KB Output is correct
58 Correct 33 ms 13584 KB Output is correct
59 Correct 35 ms 13596 KB Output is correct
60 Correct 30 ms 13588 KB Output is correct
61 Correct 28 ms 13600 KB Output is correct
62 Correct 29 ms 13588 KB Output is correct
63 Correct 33 ms 13508 KB Output is correct
64 Correct 29 ms 13512 KB Output is correct
65 Correct 30 ms 14480 KB Output is correct
66 Correct 30 ms 13608 KB Output is correct
67 Correct 30 ms 14272 KB Output is correct
68 Correct 555 ms 13484 KB Output is correct
69 Correct 710 ms 13596 KB Output is correct
70 Correct 889 ms 13480 KB Output is correct
71 Correct 725 ms 13480 KB Output is correct
72 Correct 760 ms 13480 KB Output is correct
73 Correct 858 ms 13592 KB Output is correct
74 Correct 886 ms 13576 KB Output is correct
75 Correct 657 ms 13608 KB Output is correct
76 Correct 597 ms 14332 KB Output is correct
77 Correct 559 ms 13504 KB Output is correct
78 Correct 643 ms 13864 KB Output is correct
79 Correct 644 ms 13504 KB Output is correct
80 Correct 589 ms 14376 KB Output is correct
81 Correct 0 ms 208 KB Output is correct
82 Correct 1 ms 464 KB Output is correct
83 Correct 1 ms 464 KB Output is correct
84 Correct 32 ms 13512 KB Output is correct
85 Correct 29 ms 13476 KB Output is correct
86 Correct 29 ms 13516 KB Output is correct
87 Correct 33 ms 14424 KB Output is correct
88 Correct 35 ms 13504 KB Output is correct
89 Correct 29 ms 13504 KB Output is correct
90 Correct 28 ms 13600 KB Output is correct
91 Correct 38 ms 13604 KB Output is correct
92 Correct 35 ms 14384 KB Output is correct
93 Correct 30 ms 13620 KB Output is correct
94 Correct 1 ms 464 KB Output is correct
95 Correct 1 ms 464 KB Output is correct
96 Correct 1 ms 464 KB Output is correct
97 Correct 1 ms 464 KB Output is correct
98 Correct 1 ms 464 KB Output is correct
99 Correct 1 ms 464 KB Output is correct
100 Correct 1 ms 464 KB Output is correct
101 Correct 1 ms 464 KB Output is correct
102 Correct 1 ms 464 KB Output is correct
103 Correct 1 ms 464 KB Output is correct
104 Correct 683 ms 12068 KB Output is correct
105 Correct 735 ms 13592 KB Output is correct
106 Correct 662 ms 13596 KB Output is correct
107 Correct 757 ms 13504 KB Output is correct
108 Correct 868 ms 13596 KB Output is correct
109 Correct 875 ms 13512 KB Output is correct
110 Correct 837 ms 13480 KB Output is correct
111 Correct 653 ms 13616 KB Output is correct
112 Correct 634 ms 14348 KB Output is correct
113 Correct 645 ms 13624 KB Output is correct
114 Correct 665 ms 13976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 292 ms 8164 KB 31st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -