제출 #1020307

#제출 시각아이디문제언어결과실행 시간메모리
1020307MohamedFaresNebili밀림 점프 (APIO21_jumps)C++14
21 / 100
4081 ms14524 KiB
#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); queue<int> Q; for(int l = A; l <= B; l++) { dis[l] = 0; Q.push(l); } while(!Q.empty()) { int U = Q.front(); Q.pop(); for(auto V : adj[U]) { if(dis[U] + 1 < dis[V]) { dis[V] = dis[U] + 1; Q.push(V); } } } int res = 1e9 + 7; for(int l = C; l <= D; l++) res = min(res, dis[l]); return (res == 1e9 + 7 ? -1 : res); }
#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...