이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "jumps.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=2e3+7, INF=1e9+7;
int T[LIM], lewo[LIM], prawo[LIM], odl[LIM], n;
void init(int N, vector<int>H) {
n=N;
rep(i, n) T[i]=H[i];
rep(i, n) {
lewo[i]=prawo[i]=i;
for(int j=i-1; j>=0; --j) if(T[j]>T[i]) {
lewo[i]=j;
break;
}
for(int j=i+1; j<n; ++j) if(T[j]>T[i]) {
prawo[i]=j;
break;
}
}
}
int minimum_jumps(int a, int b, int l, int r) {
rep(i, n) odl[i]=INF;
queue<int>q;
for(int i=a; i<=b; ++i) {
odl[i]=0;
q.push(i);
}
while(!q.empty()) {
int p=q.front(); q.pop();
if(l<=p && p<=r) return odl[p];
if(odl[lewo[p]]==INF) {
odl[lewo[p]]=odl[p]+1;
q.push(lewo[p]);
}
if(odl[prawo[p]]==INF) {
odl[prawo[p]]=odl[p]+1;
q.push(prawo[p]);
}
}
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... |