Submission #1218364

#TimeUsernameProblemLanguageResultExecution timeMemory
1218364HappyCapybaraDungeons Game (IOI21_dungeons)C++17
63 / 100
3986 ms615324 KiB
#include "dungeons.h" #include<bits/stdc++.h> using namespace std; #define ll long long int jl = 25; int ex = 2; int chk = 25; int n; vector<int> s, p, w, l; //vector<vector<vector<vector<ll>>>> g; int nek[50005][25][25]; ll g[50005][25][25][2]; void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l){ //cout << "a" << endl; ::n = n; ::s = s; ::s.push_back(0); ::p = p; ::p.push_back(0); ::w = w; ::w.push_back(n); ::l = l; ::l.push_back(n); //cout << "b" << endl; for (int k=0; k<chk; k++){ //cout << k << endl; for (int i=0; i<=n; i++){ if (s[i] <= pow(ex, k)){ nek[i][k][0] = ::w[i]; g[i][k][0][0] = ::s[i]; g[i][k][0][1] = (ll)pow(10, 9); } else { nek[i][k][0] = ::l[i]; g[i][k][0][0] = ::p[i]; g[i][k][0][1] = ::s[i]; } } for (int j=1; j<jl; j++){ for (int i=0; i<n+1; i++){ nek[i][k][j] = nek[nek[i][k][j-1]][k][j-1]; g[i][k][j][0] = g[i][k][j-1][0]+g[nek[i][k][j-1]][k][j-1][0]; g[i][k][j][1] = min(g[i][k][j-1][1], g[nek[i][k][j-1]][k][j-1][1]-g[i][k][j-1][0]); } } } //cout << "d" << endl; return; } ll simulate(int x, int z2){ ll z = z2; while (x != n){ //cout << x << " " << z << endl; int k = min(chk-1, (int) floor(log(z)/log(ex))); for (int j=jl-1; j>=0; j--){ if (k == 24 || (z + g[x][k][j][0] < pow(ex, k+1) && z < g[x][k][j][1])){ z += g[x][k][j][0]; x = nek[x][k][j]; } } if (z >= s[x]){ z += s[x]; x = w[x]; } else { z += p[x]; x = l[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...