# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
464017 | prvocislo | Rainforest Jumps (APIO21_jumps) | C++17 | 1764 ms | 47936 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 <vector>
using namespace std;
const int logn = 19, maxn = 2e5+5;
//const int logn = 19, maxn = 10;
int jumpl[logn][maxn], jumpr[logn][maxn], high[logn][maxn];
int n, top, h[maxn], stk[maxn];
void init(int N, vector<int> H)
{
n = N, top = 0;
for (int i = 1; i <= n; i++) h[i] = H[i - 1];
for (int i = 1; i <= n; i++)
{
while (top && h[stk[top - 1]] < h[i]) jumpr[0][stk[top - 1]] = i, top--;
if (top) jumpl[0][i] = stk[top - 1];
stk[top++] = i;
}
for (int i = 1; i <= n; i++)
{
int l = jumpl[0][i], r = jumpr[0][i];
if (!r || (l && r && h[l] > h[r])) high[0][i] = l;
else high[0][i] = r;
}
for (int l = 1; l < logn; l++) for (int i = 1; i <= n; i++)
{
jumpl[l][i] = jumpl[l - 1][jumpl[l - 1][i]];
jumpr[l][i] = jumpr[l - 1][jumpr[l - 1][i]];
high[l][i] = high[l - 1][high[l - 1][i]];
}
# | 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... |