This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dungeons.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll binary[25][100000][25][3];//index, +, max excluded
void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l) {
s.push_back(0);
p.push_back(0);
w.push_back(n);
l.push_back(n);
n++;
for (int range = 0; range < 25; range++)
{
ll r = 1 << range;
for (int i = 0; i < n; i++)
{
if (s[i] <= r) {
binary[range][i][0][0] = w[i];
binary[range][i][0][1] = s[i];
binary[range][i][0][2] = LLONG_MAX;
} else {
binary[range][i][0][0] = l[i];
binary[range][i][0][1] = p[i];
binary[range][i][0][2] = s[i];
}
}
for (int i = 1; i < 25; i++)
{
for (int ind = 0; ind < n; ind++)
{
int pointer = binary[range][ind][i - 1][0];
binary[range][ind][i][0] = binary[range][pointer][i - 1][0];
binary[range][ind][i][1] = binary[range][ind][i - 1][1] + binary[range][pointer][i - 1][1];
binary[range][ind][i][2] = min(binary[range][ind][i - 1][2], binary[range][pointer][i - 1][2] - binary[range][ind][i - 1][1]);
}
}
}
}
long long simulate(int x, int z) {
ll t = z;
for (int r = 0; r < 24; r++)
{
for (int s = 24; s >= 0; s--)
{
if (binary[r][x][s][2] > t) {
t += binary[r][x][s][1];
x = binary[r][x][s][0];
}
}
}
t += binary[24][x][24][1];
return t;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |