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/extc++.h"
using namespace std;
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t;
((cerr << " | " << u), ...);
cerr << endl;
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
dbgh(__VA_ARGS__)
#else
#define dbg(...)
#define cerr \
if (false) \
cerr
#endif
using ll = long long;
#define endl "\n"
#define long int64_t
#define sz(x) int(std::size(x))
struct Dungeon {
int s, p, w, l;
};
struct Solver {
static constexpr int LOGN = 60;
int n;
vector<Dungeon> arr;
Solver() {}
Solver(const vector<Dungeon>& arr) : n(sz(arr)), arr(arr) {}
long query(int u, long kv) {
while (u != n) {
if (kv >= arr[u].s) {
kv += arr[u].s;
u = arr[u].w;
} else {
kv += arr[u].p;
u = arr[u].l;
}
}
return kv;
}
} solver;
void init(int n,
vector<int> arr_s,
vector<int> arr_p,
vector<int> arr_w,
vector<int> arr_l) {
vector<Dungeon> arr;
for (int i = 0; i < n; i++) {
arr.push_back({arr_s[i], arr_p[i], arr_w[i], arr_l[i]});
}
solver = Solver(arr);
}
ll simulate(int u, int kv) {
return solver.query(u, kv);
}
# | 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... |