Submission #1027845

#TimeUsernameProblemLanguageResultExecution timeMemory
1027845edogawa_somethingDungeons Game (IOI21_dungeons)C++17
13 / 100
72 ms50380 KiB
#include "dungeons.h" #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vii; typedef pair<ll,ll> pii; #define F first #define S second #define pb push_back #define all(v) v.begin(),v.end() const ll M=4e5+10; const ll inf=2e18; const ll lg=30; ll go[lg][M],sm[lg][M],awin[M],difficulty; void init(int n,vector<int>s,vector<int>p,vector<int>w,vector<int>l) { l.pb(n); p.pb(0); awin[n]=0; for(int i=n-1;i>=0;i--){ awin[i]=awin[w[i]]+s[0]; } difficulty=s[0]; for(int i=0;i<=n;i++) go[0][i]=l[i],sm[0][i]=p[i]; for(int bit=1;bit<lg;bit++){ for(int i=0;i<=n;i++){ sm[bit][i]=sm[bit-1][i]+sm[bit-1][go[bit-1][i]]; go[bit][i]=go[bit-1][go[bit-1][i]]; } } } long long simulate(int x, int zz){ ll z=zz; for(int bit=lg-1;bit>=0;bit--){ if(z+sm[bit][x]<difficulty) z+=sm[bit][x],x=go[bit][x]; } if(z<difficulty) z+=sm[0][x],x=go[0][x]; z+=awin[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...