이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;
typedef string str;
typedef vector<int> vi;
int n, sm;
vi s, p, w, l;
void init(int n1, std::vector<int> s1, std::vector<int> p1, std::vector<int> w1, std::vector<int> l1)
{
	n = n1;
	s = s1;
	p = p1;
	w = w1;
	l = l1;
	sm = *max_element(s.begin(), s.end());
}
long long solve(int x, long long z)
{
	if (z >= sm)
	{
		queue<int> q;
		q.push(x);
		while (!q.empty())
		{
			int a = q.front();
			q.pop();
			if (a != n)
			{
				z += s[0];
				q.push(w[a]);
			}
		}
		return z;
	}
	else
	{
		if (x == n)
			return z;
		if (z >= s[x])
			return solve(w[x], z + s[x]);
		else
			return solve(l[x], z + p[x]);
	}
}
long long simulate(int x, int z)
{
	return solve(x, (long long)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... |