#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N=201000;
#define LOGN 25
int a[N],l[N],r[N],mn[N][LOGN],mx[N][LOGN];
bool check(int x,int y) {
if (x==y) return true;
per(i,0,LOGN) if (a[mn[x][i]]<a[y]) x=mn[x][i];
return mn[x][0]==y;
}
void init(int n,int*h) {
rep(i,0,n) a[i]=h[i];
stack<int> stk;
rep(i,0,n) {
while (SZ(stk)&&h[stk.top()]<h[i]) stk.pop();
if (SZ(stk)) l[i]=stk.top(); else l[i]=i;
stk.push(i);
}
while (SZ(stk)) stk.pop();
per(i,0,n) {
while (SZ(stk)&&h[stk.top()]<h[i]) stk.pop();
if (SZ(stk)) r[i]=stk.top(); else r[i]=i;
stk.push(i);
}
rep(i,0,n) mn[i][0]=(h[l[i]]<h[r[i]]?l[i]:r[i]);
rep(i,0,n) mn[i][0]=(h[l[i]]>h[r[i]]?l[i]:r[i]);
rep(j,1,LOGN) rep(i,0,n) mn[i][j]=mn[mn[i][j-1]][j-1];
rep(j,1,LOGN) rep(i,0,n) mx[i][j]=mx[mx[i][j-1]][j-1];
}
int minimum_jumps(int a,int b,int c,int d) {
if (!check(a,c)) return -1;
int ans=0;
per(i,0,LOGN) if (check(mx[a][i],c)) ans+=(1<<i),a=mx[a][i];
return ans;
}
Compilation message
/usr/bin/ld: /tmp/ccwNGfYd.o: in function `main':
stub.cpp:(.text.startup+0x177): undefined reference to `init(int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status