이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> S,P,W,L;
long long cost[6], N, bjto[6][100100][25], bjad[6][100100][25];
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;
map<int, vector<int>> mp;
for(int i = 0; i < n; i++)
mp[s[i]].push_back(i);
int cnt = 0;
for(auto i: mp)
cost[cnt++] = i.first;
cost[cnt] = 1e18;
for(int i = 0; i <= cnt; i++) {
for(int j = 0; j < n; j++) {
if(cost[i]>s[j]) {
bjto[i][j][0]=w[j];
bjad[i][j][0]=s[j];
} else {
bjto[i][j][0]=l[j];
bjad[i][j][0]=p[j];
}
}
bjto[i][n][0]=n;
for(int k = 1; k < 25; k++) {
for(int j = 0; j <= n; j++) {
bjto[i][j][k]=bjto[i][bjto[i][j][k-1]][k-1];
bjad[i][j][k]=bjad[i][j][k-1]+bjad[i][bjto[i][j][k-1]][k-1];
}
}
}
return;
}
long long simulate(int x, int Z) {
long long z = Z;
int lev = 0;
while(x!=N) {
while(z>=cost[lev]) lev++;
for(int i = 25; i--;)
if(z+bjad[lev][x][i]<cost[lev])
z+=bjad[lev][x][i], x = bjto[lev][x][i];
z+=bjad[lev][x][0];
x=bjto[lev][x][0];
}
return z;
}
# | 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... |