제출 #437635

#제출 시각아이디문제언어결과실행 시간메모리
437635yiqilim5438던전 (IOI21_dungeons)C++17
0 / 100
758 ms807508 KiB
#include<bits/stdc++.h> #include"dungeons.h" using namespace std; typedef long long ll; typedef pair<int,int> pii; int n; vector<int>s,p,w,l; vector<int>tt(5e4+5,0ll); vector<vector<pii>>ls(1005,vector<pii>(5e4+5)); 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 = n-1;i>=0;i--){ tt[i] = s[i]+tt[w[i]]; } for(int i = 0;i<n;i++){ int x = i; for(int j = 1;j<=1000;j++){ ls[i][j].first = ls[i][j-1].first+p[x]; if(ls[i][j].first>=1e7) ls[i][j].first = 1e7; x = l[x]; ls[i][j].second = x; } } }; ll simulate(int x,int z){ if(z>=s[x]){ return z+tt[x]; } else{ if(z+ls[x][1000].first>=s[x]){ while(true){ if(z>=s[x]) return z+tt[x]; else z += p[x]; x = l[x]; } } else{ z += ls[x][1000].first; x = ls[x][1000].second; return simulate(x,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...