제출 #1053157

#제출 시각아이디문제언어결과실행 시간메모리
1053157MarwenElarbi던전 (IOI21_dungeons)C++17
0 / 100
8 ms22620 KiB
#include <bits/stdc++.h> using namespace std; #include "dungeons.h" #define pb push_back const int nax=4e5+5; vector<int> adj[nax]; vector<int> ss,ll,ww,pp; int depth[nax]; int N; int dfs(int x){ if(x==N) return 0; if(depth[x]!=0) return depth[x]; depth[x]=1; depth[x]+=dfs(ss[x]); return depth[x]; } void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) { ss=s; pp=p; ww=w; ll=l; N=n; for (int i = 0; i < n; ++i) { adj[i].pb(ww[i]); } for (int i = 0; i < n; ++i) { if(depth[i]==0) dfs(i); } return; } long long simulate(int x, int z) { long long ans=z; if(ans>=ss[x]) return ans+1ll*(1+depth[ww[x]])*ss[x]; else return ans+1ll*(1+depth[ll[x]])*ss[x]; }
#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...