# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
441124 | A_D | Dungeons Game (IOI21_dungeons) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dungeons.h"
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const LL L=30;
const LL N=4e5+100;
const LL H=7;
LL st[N][L][H];
LL cost[N][L][H];
set<LL> stt;
vector<LL> vec;
LL nn;
vector<LL> s,p,w,l;
void init(LL n,vector<int> S,vector<int> P,vector<int> W,vector<int> LLL){
for(int i=0;i<nn;i++){
s.push_back(S[i]);
p.push_back(P[i]);
w.push_back(W[i]);
l.push_back(LLL[i]);
}
nn=n;
for(int i=0;i<nn;i++){
stt.insert(s[i]);
}
if(stt.size()>5)assert(0);
vec.push_back(0);
for(auto x:stt)vec.push_back(x);
while(vec.size()<H+1){
vec.push_back(1e9);
}
for(int h=0;h<H;h++){
st[nn][0][h]=nn;
for(int i=0;i<nn;i++){
if(vec[h]>=s[i]){
st[i][0][h]=w[i];
cost[i][0][h]=s[i];
}
else{
st[i][0][h]=l[i];
cost[i][0][h]=p[i];
}
}
}
for(int h=0;h<H;h++){
for(int j=1;j<L;j++){
for(int i=0;i<=nn;i++){
st[i][j][h]=st[st[i][j-1][h]][j-1][h];
cost[i][j][h]=cost[i][j-1][h]+cost[st[i][j-1][h]][j-1][h];
}
}
}
}
long long simulate(int xx, int zz){
LL x=xx;
LL z=zz;
for(int h=0;h<H;h++){
for(int j=L-1;j>=0;j--){
LL nx=st[x][j][h];
LL c=z+cost[x][j][h];
if(c<vec[h+1]&&x!=nn){
x=nx;
x=c;
}
}
if(x!=nn&&z<vec[h+1]){
z+=cost[x][0][h];
x=st[x][0][h];
}
}
return z;
}