Submission #789724

#TimeUsernameProblemLanguageResultExecution timeMemory
789724Mouad_oujDungeons Game (IOI21_dungeons)C++17
0 / 100
29 ms5808 KiB
#include<bits/stdc++.h> #include "dungeons.h" using namespace std; int ans=0,nn; vector<int> se,le,pe,we,dis; vector<bool> vis; int dfs(int x) { if(x==nn) return 0; vis[x]=true; if(dis[we[x]]==-1) dis[x]=dfs(we[x])+se[x]; else dis[x]=dis[we[x]]+se[x]; return dis[x]; } void init(int n,vector<int> s,vector<int> p,vector<int> w,vector<int> l) { se.resize(n); le.resize(n); pe.resize(n); we.resize(n); dis.assign(n,-1); vis.assign(n,false); nn=n; se=s; le=l; we=w; pe=p; for(int x=0;x<n;x++) { if(!vis[x]) dfs(x); } } long long self(int x,int z) { if(x==nn) return z; if(z>=se[x]) return z+dis[x]; if(z<se[x]) return self(le[x],z+pe[x]); return 0ll; } long long simulate(int x, int z) { return self(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...