# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
497526 | Karliver | 밀림 점프 (APIO21_jumps) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(20) << (x)
#define all(v) (v).begin(), (v).end()
using namespace std;
#define forn(i,n) for (int i = 0; i < (n); ++i)
#define rforn(i, n) for(int i = (n) - 1;i >= 0;--i)
#define sz(x) (int)x.size()
#define ff first
#define se second
#define mp make_pair
using ll = long long;
int mod = (ll)1e9 + 7;
const int INF = 1e9 + 1;
const double eps = 1e-7;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<class T, size_t SZ> using AR = array<T, SZ>;
template<class T> using PR = pair<T, T>;
template <typename XPAX>
bool ckma(XPAX &x, XPAX y) {
return (x < y ? x = y, 1 : 0);
}
template <typename XPAX>
bool ckmi(XPAX &x, XPAX y) {
return (x > y ? x = y, 1 : 0);
}
V<int> g[200001];
int dis[200001];
void init(int N, int H[]) {
stack<int> st;
forn(i, N) {
while(sz(st) && H[st.top()] < H[i])
st.pop();
g[i].push_back(st.top());
st.push(i);
}
while(sz(st))st.pop();
rforn(i, N) {
while(sz(st) && H[st.top()] < H[i])
st.pop();
g[i].push_back(st.top());
st.push(i);
}
forn(i, N) {
dis[i] = -1;
}
}
int minimum_jumps(int A, int B, int C, int D) {
queue<int> q;
V<int> clr;
for(int a = A;a <= B;++a) {
q.push(a);
dis[a] = 0;
}
while(sz(q)) {
int v = q.front();
q.pop();
if(C <= v && v <= D)
return dis[v];
for(auto c : g[v]) {
if(dis[c] == -1) {
dis[c] = dis[v]+1;
q.push(c);
}
}
}
return -1;
}