Submission #940764

# Submission time Handle Problem Language Result Execution time Memory
940764 2024-03-07T15:26:46 Z Trisanu_Das Radio Towers (IOI22_towers) C++17
56 / 100
720 ms 14560 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 283 ms 8372 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 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 600 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 600 KB Output is correct
27 Correct 1 ms 600 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 1 ms 600 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 1 ms 600 KB Output is correct
34 Correct 1 ms 600 KB Output is correct
35 Correct 1 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 600 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 600 KB Output is correct
27 Correct 1 ms 600 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 1 ms 600 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 1 ms 600 KB Output is correct
34 Correct 1 ms 600 KB Output is correct
35 Correct 1 ms 592 KB Output is correct
36 Correct 18 ms 8892 KB Output is correct
37 Correct 34 ms 13752 KB Output is correct
38 Correct 33 ms 13668 KB Output is correct
39 Correct 30 ms 13752 KB Output is correct
40 Correct 29 ms 13744 KB Output is correct
41 Correct 31 ms 13580 KB Output is correct
42 Correct 31 ms 13748 KB Output is correct
43 Correct 31 ms 13728 KB Output is correct
44 Correct 31 ms 14512 KB Output is correct
45 Correct 29 ms 13752 KB Output is correct
46 Correct 33 ms 14080 KB Output is correct
47 Correct 32 ms 13536 KB Output is correct
48 Correct 27 ms 13536 KB Output is correct
49 Correct 28 ms 13756 KB Output is correct
50 Correct 37 ms 14500 KB Output is correct
51 Correct 29 ms 13704 KB Output is correct
52 Correct 28 ms 13752 KB Output is correct
53 Correct 27 ms 13748 KB Output is correct
54 Correct 31 ms 13744 KB Output is correct
55 Correct 32 ms 14560 KB Output is correct
56 Correct 29 ms 13752 KB Output is correct
57 Correct 28 ms 13228 KB Output is correct
58 Correct 31 ms 13728 KB Output is correct
59 Correct 29 ms 13756 KB Output is correct
60 Correct 28 ms 13744 KB Output is correct
61 Correct 28 ms 13740 KB Output is correct
62 Correct 28 ms 13756 KB Output is correct
63 Correct 39 ms 13748 KB Output is correct
64 Correct 31 ms 13752 KB Output is correct
65 Correct 30 ms 14476 KB Output is correct
66 Correct 29 ms 13516 KB Output is correct
67 Correct 31 ms 14520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 506 ms 13488 KB Output is correct
2 Correct 622 ms 13756 KB Output is correct
3 Correct 720 ms 13752 KB Output is correct
4 Correct 614 ms 13748 KB Output is correct
5 Correct 635 ms 13744 KB Output is correct
6 Correct 649 ms 13752 KB Output is correct
7 Correct 656 ms 13756 KB Output is correct
8 Correct 602 ms 13752 KB Output is correct
9 Correct 565 ms 14416 KB Output is correct
10 Correct 514 ms 13744 KB Output is correct
11 Correct 508 ms 14040 KB Output is correct
12 Correct 578 ms 13752 KB Output is correct
13 Correct 597 ms 14512 KB Output is correct
14 Correct 0 ms 596 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 32 ms 13752 KB Output is correct
18 Correct 29 ms 13752 KB Output is correct
19 Correct 28 ms 13744 KB Output is correct
20 Correct 31 ms 14552 KB Output is correct
21 Correct 27 ms 13756 KB Output is correct
22 Correct 30 ms 13696 KB Output is correct
23 Correct 28 ms 13528 KB Output is correct
24 Correct 27 ms 13504 KB Output is correct
25 Correct 30 ms 14356 KB Output is correct
26 Correct 29 ms 13752 KB Output is correct
27 Correct 1 ms 600 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 1 ms 600 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 1 ms 600 KB Output is correct
34 Correct 1 ms 600 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 172 ms 3528 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 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 600 KB Output is correct
20 Correct 1 ms 600 KB Output is correct
21 Correct 1 ms 600 KB Output is correct
22 Correct 1 ms 600 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 600 KB Output is correct
27 Correct 1 ms 600 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 1 ms 600 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 1 ms 600 KB Output is correct
34 Correct 1 ms 600 KB Output is correct
35 Correct 1 ms 592 KB Output is correct
36 Correct 18 ms 8892 KB Output is correct
37 Correct 34 ms 13752 KB Output is correct
38 Correct 33 ms 13668 KB Output is correct
39 Correct 30 ms 13752 KB Output is correct
40 Correct 29 ms 13744 KB Output is correct
41 Correct 31 ms 13580 KB Output is correct
42 Correct 31 ms 13748 KB Output is correct
43 Correct 31 ms 13728 KB Output is correct
44 Correct 31 ms 14512 KB Output is correct
45 Correct 29 ms 13752 KB Output is correct
46 Correct 33 ms 14080 KB Output is correct
47 Correct 32 ms 13536 KB Output is correct
48 Correct 27 ms 13536 KB Output is correct
49 Correct 28 ms 13756 KB Output is correct
50 Correct 37 ms 14500 KB Output is correct
51 Correct 29 ms 13704 KB Output is correct
52 Correct 28 ms 13752 KB Output is correct
53 Correct 27 ms 13748 KB Output is correct
54 Correct 31 ms 13744 KB Output is correct
55 Correct 32 ms 14560 KB Output is correct
56 Correct 29 ms 13752 KB Output is correct
57 Correct 28 ms 13228 KB Output is correct
58 Correct 31 ms 13728 KB Output is correct
59 Correct 29 ms 13756 KB Output is correct
60 Correct 28 ms 13744 KB Output is correct
61 Correct 28 ms 13740 KB Output is correct
62 Correct 28 ms 13756 KB Output is correct
63 Correct 39 ms 13748 KB Output is correct
64 Correct 31 ms 13752 KB Output is correct
65 Correct 30 ms 14476 KB Output is correct
66 Correct 29 ms 13516 KB Output is correct
67 Correct 31 ms 14520 KB Output is correct
68 Correct 506 ms 13488 KB Output is correct
69 Correct 622 ms 13756 KB Output is correct
70 Correct 720 ms 13752 KB Output is correct
71 Correct 614 ms 13748 KB Output is correct
72 Correct 635 ms 13744 KB Output is correct
73 Correct 649 ms 13752 KB Output is correct
74 Correct 656 ms 13756 KB Output is correct
75 Correct 602 ms 13752 KB Output is correct
76 Correct 565 ms 14416 KB Output is correct
77 Correct 514 ms 13744 KB Output is correct
78 Correct 508 ms 14040 KB Output is correct
79 Correct 578 ms 13752 KB Output is correct
80 Correct 597 ms 14512 KB Output is correct
81 Correct 0 ms 596 KB Output is correct
82 Correct 1 ms 600 KB Output is correct
83 Correct 1 ms 600 KB Output is correct
84 Correct 32 ms 13752 KB Output is correct
85 Correct 29 ms 13752 KB Output is correct
86 Correct 28 ms 13744 KB Output is correct
87 Correct 31 ms 14552 KB Output is correct
88 Correct 27 ms 13756 KB Output is correct
89 Correct 30 ms 13696 KB Output is correct
90 Correct 28 ms 13528 KB Output is correct
91 Correct 27 ms 13504 KB Output is correct
92 Correct 30 ms 14356 KB Output is correct
93 Correct 29 ms 13752 KB Output is correct
94 Correct 1 ms 600 KB Output is correct
95 Correct 1 ms 600 KB Output is correct
96 Correct 1 ms 600 KB Output is correct
97 Correct 1 ms 600 KB Output is correct
98 Correct 1 ms 600 KB Output is correct
99 Correct 1 ms 600 KB Output is correct
100 Correct 1 ms 600 KB Output is correct
101 Correct 1 ms 600 KB Output is correct
102 Correct 1 ms 600 KB Output is correct
103 Correct 1 ms 600 KB Output is correct
104 Correct 521 ms 12148 KB Output is correct
105 Correct 661 ms 13492 KB Output is correct
106 Correct 570 ms 13532 KB Output is correct
107 Correct 632 ms 13744 KB Output is correct
108 Correct 570 ms 13744 KB Output is correct
109 Correct 690 ms 13744 KB Output is correct
110 Correct 604 ms 13740 KB Output is correct
111 Correct 526 ms 13760 KB Output is correct
112 Correct 568 ms 14560 KB Output is correct
113 Correct 572 ms 13768 KB Output is correct
114 Correct 613 ms 14040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 283 ms 8372 KB 31st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -