#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 time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
15 ms |
5212 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
15 ms |
5464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Runtime error |
122 ms |
38956 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
28 ms |
6724 KB |
Output is correct |
3 |
Correct |
29 ms |
6828 KB |
Output is correct |
4 |
Correct |
29 ms |
6220 KB |
Output is correct |
5 |
Correct |
27 ms |
6204 KB |
Output is correct |
6 |
Execution timed out |
7058 ms |
6236 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
28 ms |
6724 KB |
Output is correct |
3 |
Correct |
29 ms |
6828 KB |
Output is correct |
4 |
Correct |
29 ms |
6220 KB |
Output is correct |
5 |
Correct |
27 ms |
6204 KB |
Output is correct |
6 |
Execution timed out |
7058 ms |
6236 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
28 ms |
6724 KB |
Output is correct |
3 |
Correct |
29 ms |
6828 KB |
Output is correct |
4 |
Correct |
29 ms |
6220 KB |
Output is correct |
5 |
Correct |
27 ms |
6204 KB |
Output is correct |
6 |
Execution timed out |
7058 ms |
6236 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Runtime error |
122 ms |
38956 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |