Submission #789727

#TimeUsernameProblemLanguageResultExecution timeMemory
789727Mouad_oujDungeons Game (IOI21_dungeons)C++17
0 / 100
7018 ms5700 KiB
#include<bits/stdc++.h> #include "dungeons.h" using namespace std; int ans=0,nn; vector<int> se,le,pe,we; vector<long long> dis; vector<bool> vis; long long 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]); } long long simulate(int x, int z) { return self(x,z); }

Compilation message (stderr)

dungeons.cpp: In function 'long long int self(int, int)':
dungeons.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
   46 | }
      | ^
#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...