Submission #443392

#TimeUsernameProblemLanguageResultExecution timeMemory
443392benedict0724Dungeons Game (IOI21_dungeons)C++17
25 / 100
396 ms241624 KiB
#include "dungeons.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; pair<int, ll> sp[50002][25][6]; pair<int, ll> Plus(pair<int, ll> x, pair<int, ll> y) { pair<int, ll> ans; ans.first = y.first; ans.second = x.second + y.second; return ans; } int S[5]; void init(int n, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) { int j = 0; for(int i=0;i<n;i++) { bool flag = true; for(int p=0;p<j;p++) if(S[p] == s[i]) flag = false; if(flag) { for(int p=j;p<5;p++) S[p] = s[i]; j++; } } sort(S, S + 5); for(int i=0;i<n;i++) sp[i][0][0] = {l[i], p[i]}; sp[n][0][0] = {n, 0}; for(int k=1;k<6;k++) { for(int i=0;i<n;i++) { if(s[i] > S[k-1]) sp[i][0][k] = {l[i], p[i]}; else sp[i][0][k] = {w[i], s[i]}; } sp[n][0][k] = {n, 0}; } for(int k=0;k<6;k++) { for(int t=1;t<=24;t++) { for(int i=0;i<=n;i++) { int next = sp[i][t-1][k].first; sp[i][t][k] = Plus(sp[i][t-1][k], sp[next][t-1][k]); } } } return; } long long simulate(int x, int z) { for(int i=0;i<5;i++) { if(z < S[i]) { for(int t=24;t>=0;t--) { if(sp[x][t][i].second + z < S[i]) { z += sp[x][t][i].second; x = sp[x][t][i].first; } } z += sp[x][0][i].second; x = sp[x][0][i].first; } } return z + sp[x][24][5].second; }
#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...