# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
484113 | MilosMilutinovic | Rainforest Jumps (APIO21_jumps) | C++14 | 1422 ms | 161692 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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++){
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |