#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=5e4+5, kx=16;
ll N, S, loc[nx][kx], c[nx][kx], dp[nx];
void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) {
N=n;
S=s[0];
for (int i=0; i<n; i++) c[i][0]=p[i], loc[i][0]=l[i];
loc[n][0]=n;
for (int i=1; i<kx; i++) for (int j=0; j<=n; j++) loc[j][i]=loc[loc[j][i-1]][i-1], c[j][i]=c[j][i-1]+c[loc[j][i-1]][i-1];
//for (int i=0; i<kx; i++) for (int j=0; j<=n; j++) cout<<i<<' '<<j<<' '<<loc[j][i]<<' '<<c[j][i]<<'\n';
for (int i=n-1; i>=0; i--) dp[i]=dp[w[i]]+s[i];
}
long long simulate(int x, int z) {
if (z>=S) return z+dp[x];
for (int i=kx-1; i>=0; i--) if (c[x][i]+z<S) z+=c[x][i], x=loc[x][i];
z+=c[x][0];
x=loc[x][0];
return z+dp[x];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
36 ms |
17340 KB |
Output is correct |
3 |
Correct |
36 ms |
17472 KB |
Output is correct |
4 |
Correct |
32 ms |
16812 KB |
Output is correct |
5 |
Correct |
32 ms |
16732 KB |
Output is correct |
6 |
Incorrect |
39 ms |
16960 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
36 ms |
17340 KB |
Output is correct |
3 |
Correct |
36 ms |
17472 KB |
Output is correct |
4 |
Correct |
32 ms |
16812 KB |
Output is correct |
5 |
Correct |
32 ms |
16732 KB |
Output is correct |
6 |
Incorrect |
39 ms |
16960 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4444 KB |
Output is correct |
2 |
Correct |
36 ms |
17340 KB |
Output is correct |
3 |
Correct |
36 ms |
17472 KB |
Output is correct |
4 |
Correct |
32 ms |
16812 KB |
Output is correct |
5 |
Correct |
32 ms |
16732 KB |
Output is correct |
6 |
Incorrect |
39 ms |
16960 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |