#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
const int LOG=30;
vector<int> s, win, p, w, l;
int n, m;
void init(signed _n, vector<signed> _s, vector<signed> _p, vector<signed> _w, vector<signed> _l) {
n=_n;
for (auto &u: _s) s.pb(u), win.pb(u);
for (auto &u: _p) p.pb(u);
for (auto &u: _w) w.pb(u);
for (auto &u: _l) l.pb(u);
set<int> left; for (int i=0; i<n; i++) left.insert(i);
int cnt=0;
while (!left.empty()) {
vector<int> toerase;
for (auto &u: left) {
cnt++;
if (w[u]!=n && win[w[u]]<=s[u]) s[u]+=s[w[u]], w[u]=w[w[u]];
else toerase.pb(u);
}
for (auto &u: toerase) left.erase(u);
assert(cnt<=50000000);
}
for (int i=0; i<n; i++) left.insert(i);
cnt=0;
while (!left.empty()) {
vector<int> toerase;
for (auto &u: left) {
cnt++;
if (l[u]!=n && win[l[u]]<=p[u]) p[u]+=s[l[u]], l[u]=w[l[u]];
else toerase.pb(u);
}
for (auto &u: toerase) left.erase(u);
assert(cnt<=50000000);
}
return;
}
int simulate(signed x, signed z) {
int ans=z;
while (x!=n) {
if (ans>=win[x]) ans+=s[x], x=w[x];
else ans+=p[x], x=l[x];
}
return ans;
}
# | 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... |