# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
740830 | nguyentunglam | Rainforest Jumps (APIO21_jumps) | C++17 | 1376 ms | 47896 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
const int N = 2e5 + 10;
int l[N], r[N], h[N], sp[20][N], lg[N], pos[N], f[20][N], g[20][N];
int n ;
int getmax(int l, int r) {
int k = lg[r - l + 1];
int x = sp[k][l], y = sp[k][r - (1 << k) + 1];
return h[x] > h[y] ? x : y;
}
void init(int _n, vector<int> H) {
stack<int> st;
n = _n;
h[n] = 1e9;
for(int i = 0; i < n; i++) h[i] = H[i], pos[h[i]] = i, sp[0][i] = i;
for(int i = 2; i <= n; i++) lg[i] = lg[i / 2] + 1;
for(int j = 1; j <= lg[n]; j++) for(int i = 0; i + (1 << j) - 1 < n; i++) {
int x = sp[j - 1][i], y = sp[j - 1][i + (1 << j >> 1)];
sp[j][i] = h[x] > h[y] ? x : y;
}
for(int i = 0; i < n; i++) {
while (!st.empty() && h[st.top()] < h[i]) st.pop();
l[i] = st.empty() ? n : st.top();
Compilation message (stderr)
# | 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... |