이 제출은 이전 버전의 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;
pair<ll,ll> jump[6][31][400005];
set<int> mys;
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;
for(int i=0;i<n;i++) mys.insert(s[i]);
mys.insert(0);
int cnt = 0;
for(auto x:mys)
{
for(int i=0;i<n;i++)
{
if(s[i]<=x) jump[cnt][0][i] = {s[i],w[i]}; //if win
else jump[cnt][0][i] = {p[i],l[i]}; //if lose
}
jump[cnt][0][n] = {0,n};
for(int i=1;i<=30;i++)
{
for(int j=0;j<=n;j++)
{
jump[cnt][i][j] = {jump[cnt][i-1][j].fir+jump[cnt][i-1][jump[cnt][i-1][j].sec].fir,
jump[cnt][i-1][jump[cnt][i-1][j].sec].sec};
}
}
cnt++;
}
return;
}
ll simulate(int x, int z)
{
int pos = x;
ll str = z;
int cnt = 0;
for(auto itr=mys.begin();itr!=mys.end();itr++)
{
int nxt;
if((++itr)!=mys.end()) nxt = *(itr),itr--;
else break;
for(int i=30;i>=0;i--)
{
if(str+jump[cnt][i][pos].fir<nxt)
{
str += jump[cnt][i][pos].fir;
pos = jump[cnt][i][pos].sec;
}
}
while(pos!=N)
{
if(str>=nxt) break;
else if(str>=S[pos]) str += S[pos], pos = W[pos];
else str += P[pos], pos = L[pos];
}
cnt++;
}
for(int i=30;i>=0;i--)
{
str += jump[cnt][i][pos].fir;
pos = jump[cnt][i][pos].sec;
}
if(pos!=N) str += jump[cnt][0][pos].fir;
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... |