제출 #617962

#제출 시각아이디문제언어결과실행 시간메모리
617962AmirElarbi밀림 점프 (APIO21_jumps)C++14
0 / 100
1 ms208 KiB
#include <bits/stdc++.h> #define vi vector<int> #define ve vector #define ll long long #define vf vector<float> #define vll vector<pair<ll,ll>> #define ii pair<int,int> #define pll pair<ll,ll> #define vvi vector<vi> #define vii vector<ii> #define gii greater<ii> #define pb push_back #define mp make_pair #define fi first #define se second #define INF 2e9+5 #define eps 1e-7 #define eps1 1e-25 #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define MAX_A 1e5+5 #define V 450 using namespace std; const int MOD = 1e9; const int nax = 4e5+5; const int lg = 25; int nxt[nax][lg]; void init(int n, vi h) { stack<ii> st; for (int i = n-1; i >= 0; --i) { while(!st.empty() && st.top().fi <= h[i]){ st.pop(); } if(st.empty()) nxt[i][0] = INF; else nxt[i][0] = st.top().se; st.push({h[i], i}); } for (int i = 1; i < lg; ++i) { for (int j = 0; j < n; ++j) { if(nxt[j][i-1] == INF) nxt[j][i] = INF; else nxt[j][i] = nxt[nxt[j][i-1]][i-1]; } } } int minimum_jumps(int a, int b, int c, int d) { int mn = INF; for (int i = a; i <= b; ++i) { int cur = i, res = 0; for (int j = 0; j < lg; ++j) { if(nxt[cur][j] <= c){ cur = nxt[cur][j]; res += (1 << j); } } if(nxt[cur][0] <= d){ mn = min(mn, res+1); } } if(mn == INF) return -1; return mn; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...