# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1152148 | Sharky | Rainforest Jumps (APIO21_jumps) | C++20 | 409 ms | 48808 KiB |
#include "jumps.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int LG = 18;
int n, sp[N][LG], h[N], pos[N], las[N], nex[N], nxt[N][LG], nxt2[N][LG], lg[N];
int query(int x, int y) {
int j = lg[y - x + 1];
return max(sp[x][j], sp[y - (1 << j) + 1][j]);
}
void init(int _n, std::vector<int> _h) {
n = _n;
for (int i = 0; i < _n; i++) {
h[i + 1] = _h[i];
sp[i + 1][0] = h[i + 1];
}
lg[1] = 0;
for (int i = 2; i <= n; i++) lg[i] = lg[i/2] + 1;
for (int i = 1; i <= n; i++) pos[h[i]] = i;
for (int i = 1; i < LG; i++) {
for (int j = 1; j + (1 << i) - 1 <= n; j++) {
sp[j][i] = max(sp[j][i - 1], sp[j + (1 << (i - 1))][i - 1]);
}
}
stack<int> st;
for (int i = 1; i <= n; i++) {
while (!st.empty() && h[st.top()] < h[i]) st.pop();
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |