Submission #983063

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
9830632024-05-15 07:37:40vjudge1Rainforest Jumps (APIO21_jumps)C++17
100 / 100
866 ms63952 KiB
#include "jumps.h"
#include <bits/stdc++.h>
using namespace std;
vector<int>adj[200100];
int vis[200100],d[200100],n,h[200100],rbj[200100][20],obj[200100][20],st[200100][20],loc[200100];
vector<int> v;
int query(int a,int b){
int x=31-__builtin_clz(b-a+1);
return max(st[a][x],st[b-(1<<x)+1][x]);
}
void init(int N, std::vector<int> H) {
stack<int> stk;
for(int i=0;i<N;i++)
loc[st[i+1][0]=h[i+1]=H[i]]=i+1;
h[0]=1e9,n=N;
for(int j=1;j<20;j++) for(int i=1;i+(1<<j)-2<n;i++)
st[i][j]=max(st[i][j-1],st[i+(1<<j-1)][j-1]);
for(int i=0;i<N;i++){
while(stk.size()&&H[stk.top()]<=H[i])
stk.pop();
if(stk.size())
adj[i+1].push_back(stk.top()+1);
stk.push(i);
}
while(stk.size())stk.pop();
for(int i=N;i--;){
while(stk.size()&&H[stk.top()]<=H[i])
stk.pop();
if(stk.size())
adj[i+1].push_back(rbj[i+1][0]=stk.top()+1);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

jumps.cpp: In function 'void init(int, std::vector<int>)':
jumps.cpp:17:43: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   17 |         st[i][j]=max(st[i][j-1],st[i+(1<<j-1)][j-1]);
      |                                          ~^~
jumps.cpp: In function 'int minimum_jumps(int, int, int, int)':
jumps.cpp:60:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   60 |         int mid=l+r>>1;
      |                 ~^~
#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...