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>
using namespace std;
int N;
vector<int> adj[200005];
vector<int> H;
void init(int _N, vector<int> _H) {
N = _N;
for(int l = 0; l < _N; l++)
H.push_back(_H[l]);
for(int l = 0; l < _N; l++) {
for(int i = l + 1; i < _N; i++) {
if(_H[i] > _H[l]) {
adj[l].push_back(i);
break;
}
}
for(int i = l - 1; i >= 0; i--) {
if(_H[i] > _H[l]) {
adj[l].push_back(i);
break;
}
}
}
}
int minimum_jumps(int A, int B, int C, int D) {
vector<int> dis(N, 1e9 + 7); priority_queue<pair<int, int>> Q;
for(int l = A; l <= B; l++) {
dis[l] = 0; Q.push({0, l});
}
while(!Q.empty()) {
pair<int, int> U = Q.top(); Q.pop();
if(-U.first > dis[U.second]) continue;
if(U.second >= C && U.second <= D) return -U.first;
for(auto V : adj[U.second]) {
if(dis[U.second] + 1 < dis[V]) {
dis[V] = dis[U.second] + 1;
Q.push({-dis[V], V});
}
}
}
return -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... |