Submission #983730

#TimeUsernameProblemLanguageResultExecution timeMemory
983730NexusRainforest Jumps (APIO21_jumps)C++17
21 / 100
4070 ms14600 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 x,y,z; queue<pair<ll,ll>>q; void init(int n,vector<int>h) { for(ll i=0;i<n;++i) { for(ll j=i-1;j>=0;--j) { if(h[j]>h[i]) { v[j].push_back(i); break; } } for(ll j=i+1;j<n;++j) { if(h[j]>h[i]) { v[j].push_back(i); break; } } } } int minimum_jumps(int A, int B, int C, int D) { x=-1; memset(vis,false,sizeof vis); for(ll i=C;i<=D;++i) for(auto j:v[i])q.push({j,1}); while(q.size()) { p=q.front(); q.pop(); if(vis[p.first])continue; vis[p.first]=1; if(A<=p.first && p.first<=B) x=(x==-1?p.second:min(x,p.second)); ++p.second; for(auto j:v[p.first])q.push({j,p.second}); } 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...