Submission #438423

#TimeUsernameProblemLanguageResultExecution timeMemory
438423mango_lassiDungeons Game (IOI21_dungeons)C++17
11 / 100
7069 ms90540 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; using ll = long long; const ll INF = 1e9 + 7; const int N = 50000; // 4 * (int)1e5; const int C = 4; const int H = 24 / C; pair<int, ll> jmp[N + 1][H][H]; ll str[N + 1]; ll bns[N + 1]; int wt[N + 1]; int lt[N + 1]; int n; pair<int, ll> advance(pair<int, ll> cur) { if (str[cur.first] > cur.second) return {lt[cur.first], bns[cur.first] + cur.second}; else return {wt[cur.first], str[cur.first] + cur.second}; } void init(int n_, vector<int> s, vector<int> p, vector<int> w, vector<int> l) { n = n_; for (int i = 0; i < n; ++i) str[i] = s[i]; for (int i = 0; i < n; ++i) bns[i] = p[i]; for (int i = 0; i < n; ++i) wt[i] = w[i]; for (int i = 0; i < n; ++i) lt[i] = l[i]; str[n] = 0; bns[n] = 0; wt[n] = n; lt[n] = n; for (int a = 0; a < H; ++a) { ll lo = 1 << (C * a); ll hi = 1 << (C * (a + 1)); for (int i = 0; i <= n; ++i) { if ((lo <= str[i] && str[i] < hi) || i == n) { jmp[i][a][0] = {i, INF}; } else if (str[i] < lo) { jmp[i][a][0] = {wt[i], str[i]}; } else { jmp[i][a][0] = {lt[i], bns[i]}; } } for (int b = 1; b < H; ++b) { for (int i = 0; i <= n; ++i) { pair<int, ll> res = {i, 0ll}; for (int it = 0; it < (1 << C); ++it) { res.second += jmp[res.first][a][b - 1].second; res.first = jmp[res.first][a][b - 1].first; } jmp[i][a][b] = res; } } } } long long simulate(int start_i, int ini_pwr) { pair<int, ll> state = {start_i, (ll)ini_pwr}; for (int a = 0; a < H; ++a) { ll lo = 1 << (C * a); ll hi = 1 << (C * (a + 1)); while(state.first != n && lo <= state.second && state.second < hi) { for (int b = H-1; b >= 0; --b) { while(state.second + jmp[state.first][a][b].second < hi) { state.second += jmp[state.first][a][b].second; state.first = jmp[state.first][a][b].first; } } state = advance(state); // either fight against opponent in same strength bracket, or break out of strength bracket } } while(state.first != n) state = advance(state); return state.second; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...