제출 #1053343

#제출 시각아이디문제언어결과실행 시간메모리
1053343Zicrus던전 (IOI21_dungeons)C++17
37 / 100
7064 ms341548 KiB
#include <bits/stdc++.h> #include "dungeons.h" using namespace std; typedef long long ll; ll n; vector<int> s, p, w, l; vector<vector<pair<ll, ll>>> jmp; vector<vector<ll>> jmpCheck; void init(int n1, vector<int> s1, vector<int> p1, vector<int> w1, vector<int> l1) { n = n1; s = s1; p = p1; w = w1; l = l1; jmp = vector<vector<pair<ll, ll>>>(n, vector<pair<ll, ll>>(30)); jmpCheck = vector<vector<ll>>(n, vector<ll>(30)); for (int i = 0; i < n; i++) { jmp[i][0] = {s[i], w[i]}; if (jmp[i][0].second == n) jmp[i][0].first = 1ll << 31ll; jmpCheck[i][0] = s[i]; } for (int j = 1; j < 30; j++) { for (int i = 0; i < n; i++) { if (jmp[i][j-1].second == n) { jmp[i][j] = {1ll << 31ll, n}; jmpCheck[i][j] = 1ll << 31ll; continue; } else if (jmp[jmp[i][j-1].second][j-1].second == n) { jmp[i][j] = {1ll << 31ll, n}; jmpCheck[i][j] = 1ll << 31ll; continue; } else { jmp[i][j] = {jmp[jmp[i][j-1].second][j-1].first + jmp[i][j-1].first, jmp[jmp[i][j-1].second][j-1].second}; } // jmpCheck jmpCheck[i][j] = max(jmpCheck[jmp[i][j-1].second][j-1] - jmp[i][j-1].first, jmpCheck[i][j-1]); } } } ll simulate(int x1, int z1) { ll i = x1, z = z1; if (i == n) return z; while (z < s[i]) { z += p[i]; i = l[i]; } while (i < n) { for (int j = 30-1; j >= 0; j--) { if (z >= jmpCheck[i][j] && jmp[i][j].second < n) { z += jmp[i][j].first; i = jmp[i][j].second; } } if (z >= s[i]) { z += s[i]; i = w[i]; } while (i < n && z < s[i]) { z += p[i]; i = l[i]; } } return z; }
#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...