# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
794529 | finn__ | Dungeons Game (IOI21_dungeons) | C++17 | 4 ms | 472 KiB |
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 <bits/stdc++.h>
#include "dungeons.h"
using namespace std;
constexpr size_t N = 400001, K = 26;
size_t n;
uint64_t f[K][N][3];
vector<int> s, p, w, l;
void init(int n_, vector<int> s_, vector<int> p_, vector<int> w_, vector<int> l_)
{
n = n_;
s = move(s_);
p = move(p_);
w = move(w_);
l = move(l_);
for (size_t i = 0; i < n; ++i)
{
f[0][i][0] = l[i];
f[0][i][1] = p[i];
f[0][i][2] = s[i];
}
f[0][n][0] = n;
for (size_t j = 0; j < K; ++j)
{
for (size_t i = 0; i < n; ++i)
{
size_t const intermediate = f[j - 1][i][0];
f[j][i][0] = f[j - 1][intermediate][0];
f[j][i][1] = f[j - 1][i][1] + f[j - 1][intermediate][1];
f[j][i][2] = max(f[j - 1][i][2], f[j - 1][intermediate][2] - min(f[j - 1][intermediate][2], f[j - 1][i][1]));
}
}
}
long long simulate(int x, int z)
{
long long strength = z;
while (x != n)
{
for (size_t j = K - 1; j < K; --j)
if (f[j][x][2] < strength)
{
strength += f[j][x][1];
x = f[j][x][0];
break;
}
if (x != n)
{
if (strength >= s[x])
{
strength += s[x];
x = w[x];
}
else
{
strength += p[x];
x = l[x];
}
}
}
return strength;
}
Compilation message (stderr)
# | 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... |