Submission #928050

#TimeUsernameProblemLanguageResultExecution timeMemory
928050bobbilykingDungeons Game (IOI21_dungeons)C++17
11 / 100
7058 ms38956 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; using ll = long long ; #define A(a) (a).begin(), (a).end() using pl = pair<ll, ll>; using vl = vector<ll>; #define F(i, l, r) for (ll i = (l); i < (r); ++i) #define FD(i, l, r) for (ll i = (l); i > (r); --i) #define K first #define V second const ll NN = 50010; const ll SN = 0; ll n; ll s[NN], p[NN], w[NN], l[NN]; bool big[NN]; pl ans[NN]; // {minimum strength needed to clear to root, bonus delta } void init(int _n, vector<int> _s, vector<int> _p, vector<int> _w, vector<int> _l) { n = _n; copy(A(_s), s); copy(A(_p), p); copy(A(_w), w); copy(A(_l), l); // precomp ans FD(i, n-1, -1) { ans[i].K = max(s[i], ans[w[i]].K - s[i]); ans[i].V = ans[w[i]].V + s[i]; } } long long simulate(int _x, int _z) { ll x = _x, z = _z; while (x - n and z <= SN) { if (z >= s[x]) z += s[x], x = w[x]; else z += p[x], x = l[x]; } if (x == n) return z; // TODO: implement some kind of bsearch dictating how far to go // dummy code { while (x - n and ans[x].K > z) { if (z >= s[x]) z += s[x], x = w[x]; else z += p[x], x = l[x]; } if (x == n) return z; return ans[x].V + z; } }
#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...