Submission #484113

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
4841132021-11-02 06:13:30MilosMilutinovicRainforest Jumps (APIO21_jumps)C++14
100 / 100
1422 ms161692 KiB
#include "jumps.h"
#include <bits/stdc++.h>
using namespace std;
const int N=200050;
const int LOG=25;
int a[N],l[N],r[N],L[N][LOG],st[N][LOG];
tuple<int,int,int> mn[N][LOG],mx[N][LOG];
int getmx(int l,int r){
int res=0;
for(int i=LOG-1;~i;i--)if(l+(1<<i)-1<=r)res=max(res,st[l][i]),l+=(1<<i);
return res;
}
void init(int n,vector<int> h){
for(int i=1;i<=n;i++)a[i]=h[i-1],st[i][0]=a[i];
for(int j=1;j<LOG;j++)for(int i=1;i+(1<<j)<=n+1;i++)st[i][j]=max(st[i][j-1],st[i+(1<<(j-1))][j-1]);
stack<int> stk;
for(int i=1;i<=n;i++){
while(!stk.empty()&&a[stk.top()]<a[i])stk.pop();
if(!stk.empty())l[i]=stk.top();
else l[i]=0;
stk.push(i);
}
while(stk.size())stk.pop();
for(int i=n;i>=1;i--){
while(!stk.empty()&&a[stk.top()]<a[i])stk.pop();
if(!stk.empty())r[i]=stk.top();
else r[i]=0;
stk.push(i);
}
for(int i=1;i<=n;i++){
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:55:6: warning: unused variable 'x' [-Wunused-variable]
   55 |  int x=getmx(C,D),pos=B;
      |      ^
#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...