# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
623941 | Hanksburger | Dungeons Game (IOI21_dungeons) | C++17 | 198 ms | 242380 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;
pair<int, long long> par[6][25][50005];
vector<int> vec;
int N;
void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l)
{
N=n;
vec.push_back(0);
for (int i=0; i<n; i++)
vec.push_back(s[i]);
sort(vec.begin(), vec.end());
vec.resize(unique(vec.begin(), vec.end())-vec.begin());
for (int i=0; i<vec.size(); i++)
{
int num=vec[i];
for (int j=0; j<n; j++)
{
if (num>=s[j])
par[i][0][j]={w[j], s[j]};
else
par[i][0][j]={l[j], p[j]};
}
par[i][0][n]={n, 0};
for (int j=1; j<=24; j++)
{
for (int k=0; k<=n; k++)
{
int u=par[i][j-1][k].first;
par[i][j][k]={par[i][j-1][u].first, par[i][j-1][k].second+par[i][j-1][u].second};
}
}
}
}
long long simulate(int x, int Z)
{
long long z=Z;
for (int i=0; i+2<=vec.size(); i++)
{
if (z>=vec[i+1])
continue;
for (int j=24; j>=0; j--)
{
if (z+par[i][j][x].second<vec[i+1])
{
z+=par[i][j][x].second;
x=par[i][j][x].first;
}
}
z+=par[i][0][x].second;
x=par[i][0][x].first;
}
int ind=vec.size()-1;
for (int i=24; i>=0; i--)
{
if (par[ind][i][x].first!=N)
{
z+=par[ind][i][x].second;
x=par[ind][i][x].first;
}
}
return z+par[ind][0][x].second;
}
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... |