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;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
typedef long long ll;
typedef vector<int> vi;
int n;
vi s, p, w, l;
const int ME = 20;
vi skp;
void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) {
::n=n;
::s=s, ::p=p, ::w=w, ::l=l;
skp.push_back(0);
forR(i, ME) skp.push_back(1 << i);
}
struct pii{int a; ll b;};
int ops = 0;
pii tWin(int x, ll z, int ig) {
assert(z >= ig);
int ci=x; ll cv = z;
while(ci != n && (s[ci] <= ig || cv < s[ci])) {
++ops;
assert(ops <= 6e6 + 10);
if(s[ci] <= ig) cv += s[ci], ci = w[ci];
else cv += p[ci], ci = l[ci];
}
return {ci, cv};
}
long long simulate(int x, int z) {
int ci = x;
ll cv = z;
for(int sk : skp) {
pii nex = tWin(ci, cv, sk);
if(nex.a == n) {
return nex.b;
}
ci=nex.a;
cv=nex.b;
assert(cv >= s[ci]);
cv += s[ci];
ci = w[ci];
}
return cv;
}
# | 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... |