Submission #1050813

#TimeUsernameProblemLanguageResultExecution timeMemory
1050813BlagojDungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "dungeons.h"

using namespace std;

#define ll long long
#define inf 1e12

const int mxn = 4e5 + 10, LOG1 = 19, LOG2 = 25;
//						   steps,     pwr
int n;
vector<int> s, p, w, l;
int go[mxn][LOG1][LOG2];
ll gain[mxn][LOG1][LOG2], lim[mxn][LOG1][LOG2];

void init(int _n, vector<int> _s, vector<int> _p, vector<int> _w, vector<int> _l) {
	n = _n, s = _s, p = _p, w = _w, l = _l;
	for (int pwr = 0; pwr < LOG2; pwr++) {
		for (int i = 0; i < n; i++) {
			if ((1LL << pwr) >= s[i]) {
				if (w[i] == n) go[i][0][pwr] = -1;
				else {
					go[i][0][pwr] = w[i];
					gain[i][0][pwr] = s[i];
					lim[i][0][pwr] = inf;
				}
			}
			else {
				if (l[i] == n) go[i][0][pwr] = -1;
				else {
					go[i][0][pwr] = l[i];
					gain[i][0][pwr] = p[i];
					lim[i][0][pwr] = s[i];
				}
			}
		}
	}	
	for (int steps = 1; steps < LOG1; steps++) {
		for (int pwr = 0; pwr < LOG2; pwr++) {
			for (int i = 0; i < n; i++) {
				int nxt = go[i][steps - 1][pwr];
				if (go[i][steps - 1][pwr] == -1 || go[nxt][steps - 1][pwr] == -1) go[i][steps][pwr] = -1;
				else {
					go[i][steps][pwr] = go[nxt][steps - 1][pwr];
					gain[i][steps][pwr] = gain[i][steps - 1][pwr] + gain[nxt][steps - 1][pwr];
					lim[i][steps][pwr] = min(lim[i][steps - 1][pwr], lim[nxt][steps - 1][pwr] - gain[i][steps - 1][pwr]);
				}
			}
		}
	}
}

ll simulate(int x, int z) {
	ll ans = z;
	while (x != n) {
		ll pwr = log2(ans);
		pwr = min(pwr, (ll) LOG2 - 1);
		for (int i = LOG1 - 1; i >= 0; i--) {
			if (go[x][i][pwr] == -1) continue;
			if (ans >= lim[x][i][pwr]) continue;
			ans += gain[x][i][pwr];
			x = go[x][i][pwr];
		}
		if (ans >= s[x]) {
			ans += s[x];
			x = w[x];
		}
		else {
			ans += p[x];
			x = l[x];
		}
	}
	return ans;
}

Compilation message (stderr)

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