제출 #834237

#제출 시각아이디문제언어결과실행 시간메모리
834237Abrar_Al_Samit던전 (IOI21_dungeons)C++17
0 / 100
7104 ms24888 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; const int nax = 4e5 + 3; int n; vector<int>s, p, w, l; int nxtBig[nax]; long long sum_toNext[nax], sum_toN[nax]; int st[nax], at = 0; void go(int i, long long sum = 0) { if(i==n) { while(at) { sum_toNext[st[at]] += sum; nxtBig[st[at]] = n; --at; } return; } while(at && s[st[at]]<s[i]) { sum_toNext[st[at]] += sum; nxtBig[st[at]] = i; --at; } ++at, st[at] = i; sum_toNext[i] = -sum; go(w[i], sum + s[i]); } long long go2(int i) { if(i==n) return 0LL; return sum_toN[i] = go2(w[i]) + s[i]; } 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; for(int i=0; i<n; ++i) { nxtBig[i] = -1; } for(int i=0; i<n; ++i) if(nxtBig[i]==-1) { go(i); } for(int i=0; i<n; ++i) if(sum_toN[i]==0) { go2(i); } } const int anax = 1e7; long long simulate(int x, int z) { long long cz = z; while(x < n && cz < anax) { if(cz >= s[x]) { cz += sum_toNext[x]; x = nxtBig[x]; } else { cz += s[x]; x = l[x]; } } cz += sum_toN[x]; return cz; }
#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...