제출 #443457

#제출 시각아이디문제언어결과실행 시간메모리
443457benedict0724던전 (IOI21_dungeons)C++17
37 / 100
542 ms215608 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; struct dungeon { int n; ll sum, x; dungeon() : dungeon(0, 0, 0) {} dungeon(int _n, ll _s, ll _x) : n(_n), sum(_s), x(_x) {} } sp[400002][21]; dungeon f(dungeon x, dungeon y) { dungeon ans; ans.n = y.n; ans.sum = x.sum + y.sum; ans.x = max(x.x, y.x - x.sum); return ans; } int N; vector<int> L, P, S; void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) { N = n; L = l; P = p; S = s; for(int i=0;i<n;i++) sp[i][0] = dungeon(w[i], s[i], s[i]); sp[n][0] = dungeon(n, 0, 0); for(int t=1;t<=20;t++) { for(int i=0;i<=n;i++) { int next = sp[i][t-1].n; sp[i][t] = f(sp[i][t-1], sp[next][t-1]); } } } long long simulate(int x, int z) { while(x != N) { if(z < S[x]) { z += P[x]; x = L[x]; } for(int t=20;t>=0;t--) { if(sp[x][t].x <= z) { z += sp[x][t].sum; x = sp[x][t].n; } } } 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...