# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
680769 | Blagoj | Dungeons Game (IOI21_dungeons) | C++17 | 1 ms | 340 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 "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> str, ls, wn, lsd, d;
int N, mx = 0;
void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) {
d.resize(n + 2, 0);
N = n, str = s, ls = p, wn = w, lsd = l;
vector<int> r(n + 2);
for (int i = 0; i < w.size(); i++) {
r[w[i]] = i;
}
for (auto x : s) mx = max(mx, x);
int pos = n;
set<int> st;
long long sum = 0;
while (!st.count(pos)) {
st.insert(pos);
if (pos != n) sum += s[pos];
d[pos] = sum;
pos = r[pos];
}
return;
}
long long simulate(int x, int z) {
while (x != N) {
if (z >= mx) {
z += d[x];
break;
}
if (z >= str[x]) {
z += str[x];
x = wn[x];
}
else {
z += ls[x];
x = lsd[x];
}
}
return z;
}
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... |