Submission #488142

#TimeUsernameProblemLanguageResultExecution timeMemory
488142yungyaoDungeons Game (IOI21_dungeons)C++17
13 / 100
126 ms28092 KiB
using namespace std; #pragma GCC optimize("Ofast") #include <iostream> #include <algorithm> #include <vector> #include <utility> #include <stack> #include <queue> #include <set> #include <map> typedef long long LL; typedef pair<int,int> pii; #define F first #define S second #define pb push_back #define mkp make_pair #define iter(x) x.begin() x.end() #define REP(n) for (int __=n;__--;) #define REP0(i,n) for (int i=0;i<n;++i) #define REP1(i,n) for (int i=1;i<=n;++i) const int maxn = 5e4+200,mod = 0; const LL inf = 0; pair <int,LL> lose[maxn][24]; int win[maxn][24],wrq; int N; void init(int n,vector <int> s,vector <int> p,vector <int> w,vector <int> l){ wrq = s[0]; N = n; REP0(i,24){ win[n][i] = n; lose[n][i] = mkp(n,0); } REP0(i,n){ win[i][0] = w[i]; lose[i][0] = mkp(l[i],p[i]); } REP1(j,23){ REP0(i,n){ win[i][j] = win[win[i][j-1]][j-1]; lose[i][j] = mkp(lose[lose[i][j-1].F][j-1].F,lose[i][j-1].S + lose[lose[i][j-1].F][j-1].S); } } } LL simulate(int x,int is){ LL z = is; if (z < wrq){ for (int i=24;i--;){ if (z + lose[x][i].S < wrq and lose[x][i].F != N){ z += lose[x][i].S; x = lose[x][i].F; } } z += lose[x][0].S; x = lose[x][0].F; } if (x == N) return z; int s = 0; for (int i=24;i--;){ if (win[x][i] != N){ x = win[x][i]; s |= (1 << i); } } return z + (LL)wrq * (s+1); }
#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...