#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 4e5;
const int lg = 61;
const int lgb = 6;
const int base = 8;
const long long inf = 1e18;
int up[lg][N][lgb];
long long min_diff[lg][N][lgb];
long long sum[lg][N][lgb];
int n;
vector<int> s, p, w, l;
void init(int nn, std::vector<int> ss, std::vector<int> pp,
std::vector<int> ww, std::vector<int> ll) {
s=ss, p = pp, w = ww, l = ll;
n = nn;
for(int _ = 0;_<lg;_++) {
for(int i = 0;i<=n;i++) {
if(i == n) {
up[_][i][0] = n;
min_diff[_][i][0] = inf;
sum[_][i][0] = 0;
}
else if(s[i] < (1ll<<_)) {
up[_][i][0] = w[i];
min_diff[_][i][0] = inf;
sum[_][i][0] = s[i];
}
else {
up[_][i][0] = l[i];
min_diff[_][i][0] = s[i];
sum[_][i][0] = p[i];
}
}
for(int l = 1;l<lgb;l++) {
for(int i = 0;i<=n;i++) {
int at = i;
long long sm = 0;
long long mn_diff = inf;
for(int k = 0;k<base;k++) {
if(min_diff[_][at][l-1] != inf)
mn_diff = min(mn_diff, min_diff[_][at][l-1]-sm);
sm+=sum[_][at][l-1];
at=up[_][at][l-1];
}
up[_][i][l-1] = at;
min_diff[_][i][l-1] = mn_diff;
sum[_][i][l-1] = sm;
}
}
}
return;
}
long long simulate(int x, int zz) {
long long z = zz;
while(1) {
if(x == n)break;
int ll = min(lg-1, (int)__lg(z));
for(int j = lgb-1;j>=0;j--) {
for(int _ = 1;_<base;_++) {
if(up[ll][x][j] == n or min_diff[ll][x][j] <= z)continue;
z += sum[ll][x][j];
x = up[ll][x][j];
}
}
if(s[x] <= z) {
z+=s[x];
x=w[x];
}
else if(s[x] > z) {
z+=p[x];
x=l[x];
}
}
return z;
}
Compilation message
/tmp/ccPxKPKt.o: in function `main':
grader.cpp:(.text.startup+0x178): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x17f): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x19d): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x1a4): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x1b0): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x1b7): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x1c3): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x1ca): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x1d6): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x1dd): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text.startup+0x1e9): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status