제출 #983645

#제출 시각아이디문제언어결과실행 시간메모리
983645Nexus밀림 점프 (APIO21_jumps)C++17
0 / 100
4041 ms15304 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const ll N=2e5+9,M=2e18+9,mod=1e9+7; bool vis[N]; pair<ll,ll>p; vector<ll>v[N]; ll a[N],n,x,y,z; priority_queue<pair<ll,ll>>q; void init(int m,vector<int>h) { n=m; for(ll i=0;i<n;++i)a[i]=h[i]; for(ll i=0;i<n;++i) { for(ll j=i-1;j>=0;--j) { if(a[j]>a[i]) { v[i].push_back(j); break; } } for(ll j=i+1;j<n;++j) { if(a[j]>a[i]) { v[i].push_back(j); break; } } } } int minimum_jumps(int A, int B, int C, int D) { x=-1; vector<ll>d(n,M); for(ll i=B;i>=A;--i) if(d[i]==M) { d[i]=0; q.push({0,i}); while(q.size()) { y=q.top().second; q.pop(); if(C<=y && y<=D) { x=(x==-1?d[y]:min(x,d[y])); continue; } for(auto j:v[y]) { if(d[j]>d[y]+1) { d[j]=d[y]+1; q.push({-d[j],j}); } } } } return x; }
#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...