# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1047483 | SN0WM4N | Rainforest Jumps (APIO21_jumps) | C++14 | 4065 ms | 7348 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;
vector<int> v;
vector<int> m_sig, m_prev;
void init(int N, std::vector<int> H) {
v = H;
m_sig.resize(N);
m_prev.resize(N);
for (int i = N - 1; i >= 0; i --) {
m_sig[i] = i;
m_prev[i] = i;
for (int j = i; j < N; j ++) {
if (H[j] > H[i]) {
m_sig[i] = j;
break;
}
}
for (int j = i; j >= 0; j --) {
if (H[j] > H[i]) {
m_prev[i] = j;
break;
}
}
}
}
int minimum_jumps(int A, int B, int C, int D) {
vector<int> vis(v.size(), 1e9);
queue<pair<int, int>> q;
for (int i = A; i <= B; i ++)
q.push({i, 0});
while (!q.empty()) {
auto [x, d] = q.front();
q.pop();
if (vis[x] <= d)
continue;
if (C <= x && x <= D)
return d;
vis[x] = d;
q.push({m_sig[x], d + 1});
q.push({m_prev[x], d + 1});
}
return -1;
}
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... |