이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 10;
const int INF = 1e18 + 10;
struct esim {
int mindiff;
int pos;
int strength;
};
esim dp[N][30][30];
int NN;
vector <int> ss, pp, ww, ll;
void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l) {
NN = n;
s.push_back(0);
p.push_back(0);
w.push_back(n);
l.push_back(n);
ss = s;
pp = p;
ww = w;
ll = l;
for (int k = 0; k < 30; k++) {
for (int i = 0; i <= n; i++) {
for (int j = 0; j < 30; j++) {
if (k == 0) {
dp[i][j][k].pos = ((1 << j) >= s[i]) ? w[i] : l[i];
dp[i][j][k].strength = ((1 << j) >= s[i]) ? s[i] : p[i];
dp[i][j][k].mindiff = ((1 << j) < s[i]) ? s[i] : INF;
}
else {
dp[i][j][k].pos = dp[dp[i][j][k - 1].pos][j][k - 1].pos;
dp[i][j][k].strength = dp[i][j][k - 1].strength + dp[dp[i][j][k - 1].pos][j][k - 1].strength;
dp[i][j][k].mindiff = min(dp[i][j][k - 1].mindiff, dp[dp[i][j][k - 1].pos][j][k - 1].mindiff - dp[i][j][k - 1].strength);
}
}
}
}
}
long long simulate(int x, int z) {
while (1) {
int v = log2l(z);
for (int k = 29; k >= 0; k--) {
if (dp[x][v][k].pos == NN || dp[x][v][k].mindiff <= z || log2l(z + dp[x][v][k].strength) > v) continue;
z += dp[x][v][k].strength;
x = dp[x][v][k].pos;
}
if (z >= ss[x]) {
z += ss[x];
x = ww[x];
}
else {
z += pp[x];
x = ll[x];
}
if (dp[x][v][0].pos == NN) return z;
}
return z;
}
컴파일 시 표준 에러 (stderr) 메시지
dungeons.cpp:5:22: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
5 | const int INF = 1e18 + 10;
| ~~~~~^~~~
# | 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... |