# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
437838 | WnRS | Dungeons Game (IOI21_dungeons) | C++17 | 0 ms | 0 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;
int nnn;
vector<int>sss,ppp,www,lll;
void init(int nn, vector<int> ss, vector<int> pp, vector<int> ww, vector<int> ll) {
nnn=nn;
sss=ss,ppp=pp,www=ww,lll=ll;
}
int64_t simulate(int x, int z) {
// enter dungeon x => strength s[x]
// strength += s[x] if win
// if win: goto w[x]
// lose: increase by p[x]
// goto l[x];
while(x != nnn) {
if(z >= sss[x]) {
z+=sss[x];
x=www[x];
} else {
z+=ppp[x];
x=lll[x];
}
}
return z;
}