Submission #1057483

#TimeUsernameProblemLanguageResultExecution timeMemory
1057483TrentDungeons Game (IOI21_dungeons)C++17
0 / 100
7098 ms19760 KiB
#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; if(s[ci] <= ig) cv += s[ci], x = 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) { cerr << ops << '\n'; return nex.b; } ci=nex.a; cv=nex.b; assert(cv >= s[ci]); cv += s[ci]; ci = w[ci]; } return cv; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...