# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
798307 | Soumya1 | Rainforest Jumps (APIO21_jumps) | C++17 | 1026 ms | 50472 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 mxN = 2e5 + 5;
const int lg = 20;
int a[mxN], righ[mxN][lg], lef[mxN][lg], best[mxN][lg];
void init(int N, vector<int> H) {
for (int i = 1; i <= N; i++) a[i] = H[i - 1];
stack<int> st;
for (int i = 1; i <= N; i++) {
while (!st.empty() && a[st.top()] < a[i]) st.pop();
if (st.empty()) lef[i][0] = i;
else lef[i][0] = st.top();
st.push(i);
}
while (!st.empty()) st.pop();
for (int i = N; i >= 1; i--) {
while (!st.empty() && a[st.top()] < a[i]) st.pop();
if (st.empty()) righ[i][0] = i;
else righ[i][0] = st.top();
st.push(i);
}
for (int i = 1; i <= N; i++) {
if (a[righ[i][0]] > a[lef[i][0]]) best[i][0] = righ[i][0];
else best[i][0] = lef[i][0];
}
for (int j = 1; j < lg; j++) {
for (int i = 1; i <= N; i++) {
best[i][j] = best[best[i][j - 1]][j - 1];
righ[i][j] = righ[righ[i][j - 1]][j - 1];
# | 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... |