#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct dungeon
{
int n; ll sum, x;
dungeon() : dungeon(0, 0, 0) {}
dungeon(int _n, ll _s, ll _x) : n(_n), sum(_s), x(_x) {}
} sp[400002][21];
dungeon f(dungeon x, dungeon y)
{
dungeon ans;
ans.n = y.n;
ans.sum = x.sum + y.sum;
ans.x = max(x.x, y.x - x.sum);
return ans;
}
int N;
vector<int> L, P, S;
void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) {
N = n;
L = l;
P = p;
S = s;
for(int i=0;i<n;i++)
sp[i][0] = dungeon(w[i], s[i], s[i]);
sp[n][0] = dungeon(n, 0, 0);
for(int t=1;t<=20;t++)
{
for(int i=0;i<=n;i++)
{
int next = sp[i][t-1].n;
sp[i][t] = f(sp[i][t-1], sp[next][t-1]);
}
}
}
long long simulate(int x, int z) {
while(x != N)
{
if(z < S[x])
{
z += P[x];
x = L[x];
}
for(int t=20;t>=0;t--)
{
if(sp[x][t].x <= z)
{
z += sp[x][t].sum;
x = sp[x][t].n;
}
}
}
return z;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
197488 KB |
Output is correct |
2 |
Correct |
101 ms |
197440 KB |
Output is correct |
3 |
Correct |
106 ms |
197584 KB |
Output is correct |
4 |
Correct |
143 ms |
199660 KB |
Output is correct |
5 |
Correct |
115 ms |
197516 KB |
Output is correct |
6 |
Correct |
145 ms |
199604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
197572 KB |
Output is correct |
2 |
Correct |
542 ms |
215568 KB |
Output is correct |
3 |
Correct |
488 ms |
215564 KB |
Output is correct |
4 |
Correct |
485 ms |
215480 KB |
Output is correct |
5 |
Correct |
499 ms |
215480 KB |
Output is correct |
6 |
Correct |
542 ms |
215608 KB |
Output is correct |
7 |
Correct |
515 ms |
215604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
197512 KB |
Output is correct |
2 |
Correct |
173 ms |
200368 KB |
Output is correct |
3 |
Incorrect |
180 ms |
200388 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
197512 KB |
Output is correct |
2 |
Correct |
173 ms |
200368 KB |
Output is correct |
3 |
Incorrect |
180 ms |
200388 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
197512 KB |
Output is correct |
2 |
Correct |
173 ms |
200368 KB |
Output is correct |
3 |
Incorrect |
180 ms |
200388 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
100 ms |
197572 KB |
Output is correct |
2 |
Correct |
542 ms |
215568 KB |
Output is correct |
3 |
Correct |
488 ms |
215564 KB |
Output is correct |
4 |
Correct |
485 ms |
215480 KB |
Output is correct |
5 |
Correct |
499 ms |
215480 KB |
Output is correct |
6 |
Correct |
542 ms |
215608 KB |
Output is correct |
7 |
Correct |
515 ms |
215604 KB |
Output is correct |
8 |
Correct |
100 ms |
197512 KB |
Output is correct |
9 |
Correct |
173 ms |
200368 KB |
Output is correct |
10 |
Incorrect |
180 ms |
200388 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |