제출 #834213

#제출 시각아이디문제언어결과실행 시간메모리
834213Abrar_Al_Samit던전 (IOI21_dungeons)C++17
0 / 100
1 ms468 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] = s[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 magic = 3200; long long simulate(int x, int z) { for(int j=0; j<magic && x<n; ++j) { z += sum_toNext[x]; x = nxtBig[x]; } z += sum_toN[x]; 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...