Submission #443391

#TimeUsernameProblemLanguageResultExecution timeMemory
443391benedict0724Dungeons Game (IOI21_dungeons)C++17
Compilation error
0 ms0 KiB
#include "dungeons.h" #include <vector> 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; }

Compilation message (stderr)

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:29:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   29 |     sort(S, S + 5);
      |     ^~~~
      |     short