이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dungeons.h"
#include <bits/stdc++.h>
#define fir first
#define sec second
typedef long long ll;
using namespace std;
int N;
vector<int> S,P,W,L;
int base = 2;
const int nop = 60;
const int noa = 25;
ll jump[nop][noa][50005]; // 8^b,2^jump,pos
ll add[nop][noa][50005];
ll diff[nop][noa][50005];
void init(int n, vector<int> s, vector<int> p, vector<int> w, vector<int> l)
{
S = s; P = p; W = w; L = l; N = n;
int tmp = 1;
for(int bit=0;bit<nop;bit++)
{
int lim = tmp;
for(int i=0;i<n;i++)
{
if(s[i]<lim) add[bit][0][i] = s[i], jump[bit][0][i] = w[i];
else add[bit][0][i] = p[i], jump[bit][0][i] = l[i];
diff[bit][0][i] = add[bit][0][i]-s[i];
}
add[bit][0][n] = 0, jump[bit][0][n] = n, diff[bit][0][n] = 0;
for(int i=1;i<noa;i++)
{
for(int j=0;j<=n;j++)
{
int nxt = jump[bit][i-1][j];
add[bit][i][j] = add[bit][i-1][j] + add[bit][i-1][nxt];
diff[bit][i][j] = max(add[bit][i-1][j]-s[j], add[bit][i-1][nxt]-s[nxt]);
jump[bit][i][j] = jump[bit][i-1][nxt];
}
}
tmp *= base;
}
return;
}
ll simulate(int x, int z)
{
ll pos = x;
ll str = z;
ll tmp = 1;
ll phase = 0;
while(pos!=N && phase<nop)
{
tmp *= base;
for(int i=noa-1;i>=0;i--)
{
if(str+diff[phase][i][pos]<0)
{
str += add[phase][i][pos];
pos = jump[phase][i][pos];
}
}
while(pos!=N && str<=tmp)
{
if(str>=S[pos]) str += S[pos], pos = W[pos];
else str += P[pos], pos = L[pos];
}
phase++;
}
return str;
}
# | 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... |