#include "dungeons.h"
#include <bits/stdc++.h>
#define fir first
#define sec second
typedef long long ll;
using namespace std;
int N;
vector<int> S,P,W,L;
const int nop = 11;
const int noa = 25;
ll jump[nop][noa][50005]; // 8^b,2^jump,pos
ll add[nop][noa][50005];
ll need[nop][noa][50005]; //beat all
void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l)
{
S = s; P = p; W = w; L = l; N = n;
int tmp = 1;
for(int bit=0;bit<nop;bit++)
{
int lim = tmp;
for(int i=0;i<n;i++)
{
if(s[i]<=lim) add[bit][0][i] = s[i], jump[bit][0][i] = w[i], need[bit][0][i] = s[i];
else if(s[i]>8*lim) add[bit][0][i] = p[i], jump[bit][0][i] = l[i], need[bit][0][i] = 0;
else add[bit][0][i] = 0, jump[bit][0][i] = i, need[bit][0][i] = 0;
}
need[bit][0][n] = 0, add[bit][0][n] = 0, jump[bit][0][n] = n;
for(int i=1;i<noa;i++)
{
for(int j=0;j<=n;j++)
{
int nxt = jump[bit][i-1][j];
add[bit][i][j] = add[bit][i-1][j] + add[bit][i-1][nxt];
need[bit][i][j] = max(need[bit][i-1][j], need[bit][i-1][nxt]);
jump[bit][i][j] = jump[bit][i-1][nxt];
}
}
tmp *= 8;
}
return;
}
ll simulate(int x, int z)
{
ll pos = x;
ll str = z;
ll tmp = 1;
ll phase = 0;
while(pos!=N && phase<nop)
{
tmp *= 8;
for(int i=noa-1;i>=0;i--)
{
if(need[phase][i][pos]<=str && str+add[phase][i][pos]<=tmp && jump[phase][i][pos]!=N)
{
str += add[phase][i][pos];
pos = jump[phase][i][pos];
}
}
while(pos!=N && str<=tmp)
{
if(str>=S[pos]) str += S[pos], pos = W[pos];
else str += P[pos], pos = L[pos];
}
phase++;
}
return str;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4172 KB |
Output is correct |
2 |
Correct |
2 ms |
4300 KB |
Output is correct |
3 |
Correct |
11 ms |
17212 KB |
Output is correct |
4 |
Correct |
224 ms |
325464 KB |
Output is correct |
5 |
Correct |
12 ms |
17180 KB |
Output is correct |
6 |
Correct |
245 ms |
325568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
10736 KB |
Output is correct |
2 |
Runtime error |
1062 ms |
694868 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
10700 KB |
Output is correct |
2 |
Correct |
931 ms |
326292 KB |
Output is correct |
3 |
Incorrect |
1028 ms |
326256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
10700 KB |
Output is correct |
2 |
Correct |
931 ms |
326292 KB |
Output is correct |
3 |
Incorrect |
1028 ms |
326256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
10700 KB |
Output is correct |
2 |
Correct |
931 ms |
326292 KB |
Output is correct |
3 |
Incorrect |
1028 ms |
326256 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
10736 KB |
Output is correct |
2 |
Runtime error |
1062 ms |
694868 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |