# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
838296 | siewjh | Rainforest Jumps (APIO21_jumps) | C++17 | 1002 ms | 51376 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 "jumps.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
int nums, height[MAXN], lf[MAXN][20], rt[MAXN][20], hi[MAXN][20];
int query(int l, int r, int targ){
int ans = r;
if (height[ans] > targ) return -1;
for (int k = 19; k >= 0; k--)
if (lf[ans][k] >= l && height[lf[ans][k]] < targ)
ans = lf[ans][k];
return ans;
}
void init(int N, vector<int> H) {
nums = N;
for (int i = 1; i <= nums; i++) height[i] = H[i - 1];
height[0] = height[nums + 1] = nums + 1;
stack<pair<int, int>> s;
s.push({nums + 1, 0});
for (int i = 1; i <= nums; i++){
while (height[i] > s.top().first) s.pop();
lf[i][0] = s.top().second;
s.push({height[i], i});
}
while (s.size()) s.pop();
s.push({nums + 1, nums + 1});
for (int i = nums; i >= 1; i--){
while (height[i] > s.top().first) s.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... |