Submission #1024089

#TimeUsernameProblemLanguageResultExecution timeMemory
1024089mdn2002Dungeons Game (IOI21_dungeons)C++17
0 / 100
238 ms345256 KiB
/* Mayoeba Yabureru */ #include<bits/stdc++.h> using namespace std; long long power, st[50004][20][10], sum[50004][20][10], done[10]; vector<long long> values; int n, q; vector<int> s, p, z, w, l, x; void init(int _n, vector<int> _s, vector<int> _p, vector<int> _w, vector<int> _l) { n = _n, s = _s, p = _p, w = _w, l = _l; values.clear(); values.push_back(1e16); for (int i = 0; i < n; i ++) values.push_back(s[i]); sort(values.begin(), values.end()); } void initst() { int order = lower_bound(values.begin(), values.end(), power) - values.begin(); if (done[order]) return; for (int i = 0; i < n; i ++) { st[i][0][order] = w[i]; sum[i][0][order] = s[i]; } st[n][0][order] = n; for (int i = 1; i < 20; i ++) { for (int j = 0; j <= n; j ++) { st[j][i][order] = st[st[j][i - 1][order]][i - 1][order]; sum[j][i][order] = sum[j][i - 1][order] + sum[st[j][i - 1][order]][i - 1][order]; } } done[order] = 1; } long long simulate(int x, int z) { power = z; int cur = x; while (cur != n) { initst(); int order = lower_bound(values.begin(), values.end(), power) - values.begin(); for (int i = 19; i >= 0; i --) { if (values[order] > power) continue; power += sum[cur][i][order]; cur = st[cur][i][order]; } if (cur == n) break; if (s[cur] > power) { power += p[cur]; cur = l[cur]; } else { power += s[cur]; cur = w[cur]; } } return power; }
#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...