Submission #1210297

#TimeUsernameProblemLanguageResultExecution timeMemory
1210297steveonalexDungeons Game (IOI21_dungeons)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define MASK(i) (1ULL << (i)) #define GETBIT(mask, i) (((mask) >> (i)) & 1) #define ALL(v) (v).begin(), (v).end() ll max(ll a, ll b){return (a > b) ? a : b;} ll min(ll a, ll b){return (a < b) ? a : b;} ll gcd(ll a, ll b){return __gcd(a, b);} ll lcm(ll a, ll b){return a / gcd(a, b) * b;} ll LASTBIT(ll mask){return (mask) & (-mask);} int pop_cnt(ull mask){return __builtin_popcountll(mask);} int ctz(ull mask){return __builtin_ctzll(mask);} int logOf(ull mask){return 63 - __builtin_clzll(mask);} mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);} double rngesus_d(double l, double r){ double wow = (double) ((ull) rng()) / ((ull)(0-1)); return wow * (r - l) + l; } template <class T1, class T2> bool maximize(T1 &a, T2 b){ if (a < b) {a = b; return true;} return false; } template <class T1, class T2> bool minimize(T1 &a, T2 b){ if (a > b) {a = b; return true;} return false; } template <class T> void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){ for(auto item: container) out << item << separator; out << finish; } template <class T> void remove_dup(vector<T> &a){ sort(ALL(a)); a.resize(unique(ALL(a)) - a.begin()); } #include "dungeons.h" const int N = 4e5 + 69; const int LOG_A = 24; const ll INF = 1e18 + 69; int n; int s[N], p[N], w[N], l[N]; int nxt[LOG_A][N][LOG_A / 2]; ll cost[LOG_A][N][LOG_A / 2], barber[LOG_A][N][LOG_A / 2]; int get_layer(ll z){ if (z == 0) return 0; return min(logOf(z), LOG_A - 1); } void init(int _n, vector<int> _s, vector<int> _p, vector<int> _w, vector<int> _l){ n = _n; if (n >= N) assert(false); for(int i= 0; i < n; ++i) { s[i] = _s[i]; p[i] = _p[i]; w[i] = _w[i]; l[i] = _l[i]; } w[n] = l[n] = n; s[n] = p[n] = 0; for(int layer = 0; layer < LOG_A; ++layer){ vector<ll> s1(n+1), p1(n+1), w1(n+1); for(int i = 0; i <= n; ++i){ int cur = get_layer(s[i]); if (cur < layer){ s1[i] = INF; p1[i] = s[i]; w1[i] = w[i]; } else if (cur > layer){ s1[i] = INF; p1[i] = p[i]; w1[i] = l[i]; } else{ s1[i] = s[i]; p1[i] = p[i]; w1[i] = l[i]; } nxt[layer][i][0] = w1[i]; cost[layer][i][0] = p1[i]; barber[layer][i][0] = s1[i]; } for(int j = 1; j < LOG_A; ++j) { for(int i = 0; i <= n; ++i){ nxt[layer][i][j] = nxt[layer][i][j-1]; cost[layer][i][j] = cost[layer][i][j-1]; barber[layer][i][j] = barber[layer][i][j-1]; for(int it = 0; it < 4; ++it){ int prev = nxt[layer][i][j]; ll cur_cost = cost[layer][i][j]; nxt[layer][i][j] = nxt[layer][prev][j-1]; cost[layer][i][j] = cur_cost + cost[layer][prev][j-1]; barber[layer][i][j] = min(barber[layer][i][j], barber[layer][prev][j-1] - cur_cost); } } } } } ll simulate(int x, int z){ ll ans = z; while(true){ if (x == n) break; int layer = get_layer(ans); for(int j = LOG_A - 1; j >= 0; --j) { for(int it = 0; it < 3; ++it){ if (nxt[layer][x][j] == n) break; if (get_layer(ans + cost[layer][x][j]) != layer) break; if (ans >= barber[layer][x][j]) break; ans += cost[layer][x][j]; x = nxt[layer][x][j]; } } if (ans >= s[x]){ ans += s[x]; x = w[x]; } else{ ans += p[x]; x = l[x]; } } return ans; } /* 3 2 2 6 9 3 1 2 2 2 3 1 0 1 0 1 2 3 */

Compilation message (stderr)

/tmp/cccXMNlR.o: in function `simulate(int, int)':
dungeons.cpp:(.text+0x133): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cccXMNlR.o
dungeons.cpp:(.text+0x22d): relocation truncated to fit: R_X86_64_PC32 against symbol `s' defined in .bss section in /tmp/cccXMNlR.o
dungeons.cpp:(.text+0x23d): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cccXMNlR.o
dungeons.cpp:(.text+0x261): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/cccXMNlR.o
dungeons.cpp:(.text+0x26c): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/cccXMNlR.o
/tmp/cccXMNlR.o: in function `rngesus_d(double, double)':
dungeons.cpp:(.text+0x288): relocation truncated to fit: R_X86_64_PC32 against symbol `rng' defined in .bss section in /tmp/cccXMNlR.o
dungeons.cpp:(.text+0x293): relocation truncated to fit: R_X86_64_PC32 against symbol `rng' defined in .bss section in /tmp/cccXMNlR.o
dungeons.cpp:(.text+0x2b8): relocation truncated to fit: R_X86_64_PC32 against symbol `rng' defined in .bss section in /tmp/cccXMNlR.o
dungeons.cpp:(.text+0x371): relocation truncated to fit: R_X86_64_PC32 against symbol `rng' defined in .bss section in /tmp/cccXMNlR.o
/tmp/cccXMNlR.o: in function `rngesus(long long, long long)':
dungeons.cpp:(.text+0x387): relocation truncated to fit: R_X86_64_PC32 against symbol `rng' defined in .bss section in /tmp/cccXMNlR.o
dungeons.cpp:(.text+0x390): additional relocation overflows omitted from the output
/usr/lib/gcc/x86_64-linux-gnu/11/libstdc++.a(ios_init.o): in function `std::ios_base::Init::Init()':
(.text._ZNSt8ios_base4InitC2Ev+0x1c): failed to convert GOTPCREL relocation against '_ZNSt8ios_base4Init11_S_refcountE'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x1c6): failed to convert GOTPCREL relocation against '_ZSt4cout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x260): failed to convert GOTPCREL relocation against '_ZSt3cin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x2e2): failed to convert GOTPCREL relocation against '_ZSt4cerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x353): failed to convert GOTPCREL relocation against '_ZSt4clog'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x541): failed to convert GOTPCREL relocation against '_ZSt5wcout'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x5e5): failed to convert GOTPCREL relocation against '_ZSt4wcin'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x670): failed to convert GOTPCREL relocation against '_ZSt5wcerr'; relink with --no-relax
(.text._ZNSt8ios_base4InitC2Ev+0x6e9): failed to convert GOTPCREL relocation against '_ZSt5wclog'; relink with --no-relax
/usr/bin/ld: final link failed
collect2: error: ld returned 1 exit status