# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1082375 | HappyCapybara | Dungeons Game (IOI21_dungeons) | C++17 | 1365 ms | 2097152 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "dungeons.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;
vector<int> s, p, w, l, ds;
vector<vector<vector<pair<int,ll>>>> v;
void init(int N, vector<int> S, vector<int> P, vector<int> W, vector<int> L){
n = N;
s = S;
p = P;
w = W;
l = L;
for (int i=0; i<n; i++){
int b = true;
for (int x : ds){
if (x == s[i]) b = false;
}
if (b) ds.push_back(s[i]);
}
ds.push_back(0);
sort(ds.begin(), ds.end());
s.push_back(0);
p.push_back(0);
w.push_back(n);
l.push_back(n);
v.resize(ds.size(), vector<vector<pair<int,ll>>>(n+1, vector<pair<int,ll>>(30)));
for (int k=0; k<ds.size(); k++){
for (int i=0; i<30; i++){
for (int j=0; j<=n; j++){
if (i == 0){
if (ds[k] < s[j] ) v[k][j][i] = {l[j], p[j]};
else v[k][j][i] = {w[j], s[j]};
}
else {
v[k][j][i].first = v[k][v[k][j][i-1].first][i-1].first;
v[k][j][i].second = v[k][j][i-1].second + v[k][v[k][j][i-1].first][i-1].second;
}
}
}
}
/*for (int k=0; k<1; k++){
for (int i=0; i<n; i++){
for (int j=0; j<5; j++){
cout << v[k][i][j].first << " " << v[k][i][j].second << "\n";
}
cout << "\n";
}
}*/
return;
}
ll simulate(int x, int z){
ll y = z;
int cur = 0;
while (cur < ds.size()){
while ((cur == ds.size()-1 || y < ds[cur+1]) && x != n){
int i = 0;
while ((cur == ds.size()-1 || y+v[cur][x][i+1].second < ds[cur+1]) && v[cur][x][i].first != n) i++;
y += v[cur][x][i].second;
x = v[cur][x][i].first;
}
cur++;
}
return y;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |