제출 #1062686

#제출 시각아이디문제언어결과실행 시간메모리
1062686aufan던전 (IOI21_dungeons)C++17
0 / 100
50 ms25176 KiB
#include "dungeons.h" #include <bits/stdc++.h> #define fi first #define se second using namespace std; int n; vector<int> s, p, w, l, dp; vector<vector<pair<long long, int>>> bl; 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; dp = vector<int>(n + 1, 0); bl = vector<vector<pair<long long, int>>>(n, vector<pair<long long, int>>(25)); for (int i = n - 1; i >= 0; i--) dp[i] = dp[w[i]] + 1; for (int i = 0; i < n; i++) bl[i][0] = {p[i], l[i]}; for (int j = 1; j < 25; j++) { for (int i = 0; i < n; i++) { auto [w, k] = bl[i][j - 1]; if (k == n) { bl[i][j] = bl[i][j - 1]; } else { auto [z, x] = bl[k][j - 1]; bl[i][j] = {w + z, x}; } } } return; } long long simulate(int x, int z) { long long f = z; for (int j = 24; j >= 0; j--) { if (x == n) break; if (f + bl[x][j].fi < s[0]) { f += bl[x][j].fi; x = bl[x][j].se; } } if (f < s[0]) { f += p[x]; x = l[x]; } f += dp[x] * s[0]; return f; }
#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...