Submission #566382

#TimeUsernameProblemLanguageResultExecution timeMemory
566382kartelDungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
//#include "grader.cpp"
#include "dungeons.h"
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#pragma GCC optimize("-Ofast")
using namespace std;
typedef long long ll;

const int N = 4e5 + 500;
const int log2A = 24;
const int log2N = 20;

int up[N][log2N][log2A];
ll sum[N][log2N][log2A];
ll dp[N][log2N][log2A];
int n;

void init(int _n, vector <int> s, vector <int> p, vector <int> w, vector <int> l) {
    n = _n;
    for (int k = 0; k < log2N; k++) {
        for (int i = 0; i < n; i++) {
            if (s[i] < (1 << k)) {
                up[i][0][k] = w[i];
                sum[i][0][k] = s[i];
                dp[i][0][k] = -1e18;
            } else {
                up[i][0][k] = l[i];
                sum[i][0][k] = p[i];
                dp[i][0][k] = -s[i];
            }
        }
        for (int st = 1; st < log2N; st++) {
            for (int i = 0; i < n; i++) {
                up[i][st][k] = up[i][st - 1][k];
                sum[i][st][k] = sum[i][st - 1][k];
                dp[i][st][k] = dp[i][st - 1][k];
                for (int j = 1; j < 2; j++) {
                    dp[i][st][k] = max(dp[i][st][k], dp[up[i][st][k]][st - 1][k] + sum[i][st][k]);
                    sum[i][st][k] += sum[up[i][st][k]][st - 1][k];
                    up[i][st][k] = up[up[i][st][k]][st - 1][k];
                }
            }
        }
    }
}

ll simulate(int x, int start) {
    ll z = start;

    for (int k = 0; k < log2N; k++) {
        if (z >= (1ll << (k + 1))) {
            continue;
        }
        for (int j = log2N - 1; j >= 0; j--) {
            for (int p = 0; p < 2; p++) {
                if (z + dp[x][j][k] < 0) {
                    z += sum[x][j][k];
                    x = up[x][j][k];
                } else {
                    break;
                }
            }
        }
    }
    return z;
}

/*

3 2
2 6 9
3 1 2
2 2 3
1 0 1
0 1
2 3

*/

Compilation message (stderr)

/tmp/cc37RHAr.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