이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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], g[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];
g[0][i][0] = w[i];
g[0][i][1] = s[i];
g[0][i][2] = s[i];
}
f[0][n][0] = n;
f[0][n][1] = 0;
f[0][n][2] = UINT64_MAX >> 6;
g[0][n][0] = n;
g[0][n][1] = 0;
g[0][n][2] = UINT64_MAX >> 6;
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] = min(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;
}
컴파일 시 표준 에러 (stderr) 메시지
dungeons.cpp: In function 'long long int simulate(int, int)':
dungeons.cpp:54:14: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
54 | while (x != n)
| ~~^~~~
dungeons.cpp:57:28: warning: comparison of integer expressions of different signedness: 'uint64_t' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
57 | if (f[j][x][2] > strength)
| ~~~~~~~~~~~^~~~~~~~~~
dungeons.cpp:63:15: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Wsign-compare]
63 | if (x != n)
| ~~^~~~
# | 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... |