제출 #977500

#제출 시각아이디문제언어결과실행 시간메모리
977500SuPythony밀림 점프 (APIO21_jumps)C++17
0 / 100
4043 ms11600 KiB
#include "jumps.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> al(2*1e5,vector<int>()); void init(int n, vector<int> h) { if (h[1]>h[0]) al[0].push_back(1); if (h[n-2]>h[n-1]) al[n-1].push_back(n-2); for (int i=1; i<n-1; i++) { if (h[i-1]>h[i]) al[i].push_back(i-1); if (h[i+1]>h[i]) al[i].push_back(i+1); } } int minimum_jumps(int a, int b, int c, int d) { int ans=1e9; for (int i=a; i<=b; i++) { queue<pair<int,int>> q; q.push({i,0}); vector<int> vis(2*1e5,0); bool pos=false; int dist; while (!q.empty()) { auto u=q.front(); q.pop(); if (u.first>=c&&u.second<=d) { pos=true; dist=u.second; break; } for (int v: al[u.first]) { if (!vis[v]) { vis[v]=true; q.push({v,u.second+1}); } } } if (pos) ans=min(ans,dist); } if (ans==1e9) return -1; return ans; }
#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...