이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e9 + 7;
const int N = 4 * (int)1e5;
const int C = 2;
const int H = 24 / C;
pair<int, ll> jmp[N + 1][H][H];
ll str[N + 1];
ll bns[N + 1];
int wt[N + 1];
int lt[N + 1];
int n;
pair<int, ll> advance(pair<int, ll> cur) {
if (str[cur.first] > cur.second) return {lt[cur.first], bns[cur.first] + cur.second};
else return {wt[cur.first], str[cur.first] + cur.second};
}
void init(int n_, vector<int> s, vector<int> p, vector<int> w, vector<int> l) {
n = n_;
for (int i = 0; i < n; ++i) str[i] = s[i];
for (int i = 0; i < n; ++i) bns[i] = p[i];
for (int i = 0; i < n; ++i) wt[i] = w[i];
for (int i = 0; i < n; ++i) lt[i] = l[i];
str[n] = 0;
bns[n] = 0;
wt[n] = n;
lt[n] = n;
for (int a = 0; a < H; ++a) {
ll lo = 1 << (C * a);
ll hi = 1 << (C * (a + 1));
for (int i = 0; i <= n; ++i) {
if ((lo <= str[i] && str[i] < hi) || i == n) {
jmp[i][a][0] = {i, INF};
} else if (str[i] < lo) {
jmp[i][a][0] = {wt[i], str[i]};
} else {
jmp[i][a][0] = {lt[i], bns[i]};
}
}
for (int b = 1; b < H; ++b) {
for (int i = 0; i <= n; ++i) {
pair<int, ll> res = {i, 0ll};
for (int it = 0; it < (1 << C); ++it) {
res.second += jmp[res.first][a][b - 1].second;
res.first = jmp[res.first][a][b - 1].first;
}
jmp[i][a][b] = res;
}
}
}
}
long long simulate(int start_i, int ini_pwr) {
pair<int, ll> state = {start_i, (ll)ini_pwr};
for (int a = 0; a < H; ++a) {
ll lo = 1 << (C * a);
ll hi = 1 << (C * (a + 1));
while(state.first != n && lo <= state.second && state.second < hi) {
for (int b = H-1; b >= 0; --b) {
while(state.second + jmp[state.first][a][b].second < hi) {
state.second += jmp[state.first][a][b].second;
state.first = jmp[state.first][a][b].first;
}
}
state = advance(state); // either fight against opponent in same strength bracket, or break out of strength bracket
}
}
while(state.first != n) state = advance(state);
return state.second;
}
# | 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... |