Submission #1020308

#TimeUsernameProblemLanguageResultExecution timeMemory
1020308MohamedFaresNebiliRainforest Jumps (APIO21_jumps)C++14
21 / 100
4065 ms16976 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); priority_queue<pair<int, int>> Q; for(int l = A; l <= B; l++) { dis[l] = 0; Q.push({0, l}); } while(!Q.empty()) { pair<int, int> U = Q.top(); Q.pop(); if(-U.first > dis[U.second]) continue; if(U.second >= C && U.second <= D) return -U.first; for(auto V : adj[U.second]) { if(dis[U.second] + 1 < dis[V]) { dis[V] = dis[U.second] + 1; Q.push({-dis[V], V}); } } } return -1; }
#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...