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 <iostream>
#include <vector>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
typedef pair<int, int> pii;
vector<int> adj[2007];
bool vis[2007];
void init(int N, vector<int> H){
for(int i = 0; i < N; i++){
for(int j = i-1; j >= 0; j--){
if(H[j] > H[i]){
adj[i].pb(j);
break;
}
}
for(int j = i+1; j < N; j++){
if(H[j] > H[i]){
adj[i].pb(j);
break;
}
}
}
}
int minimum_jumps(int A, int B, int C, int D){
queue<pii> q;
for(int i = A; i <= B; i++){
q.push(mp(0, i));
vis[i] = 1;
}
while(!q.empty()){
pii u = q.front();
q.pop();
if(u.ss >= C && u.ss <= D)
return u.ff;
for(int v : adj[u.ss]){
if(!vis[v]){
q.push(mp(u.ff + 1, u.ss));
vis[v] = 1;
}
}
}
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... |