Submission #1034884

# Submission time Handle Problem Language Result Execution time Memory
1034884 2024-07-25T20:43:25 Z Boas Dungeons Game (IOI21_dungeons) C++17
0 / 100
7000 ms 1116 KB
#include <bits/stdc++.h>
using namespace std;

#define loop(x, i) for (int i = 0; i < x; i++)
#define rev(x, i) for (int i = (int)x - 1; i >= 0; i--)
#define loop1(x, i) for (int i = 1; i <= x; i++)
#define ALL(x) begin(x), end(x)
#define pb push_back
#define int long long

typedef vector<int> vi;
typedef vector<signed> vi32;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;

#include "dungeons.h"

int N;
vi32 S, P, W, L;
vvi winP, winD, maxS;

void init(signed n, vi32 s, vi32 p, vi32 w, vi32 l)
{
	N = n;
	S = s;
	P = p;
	W = w;
	L = l;
	winP = maxS = winD = vvi(30, vi(n + 1));
	loop(n, i)
	{
		winD[0][i] = s[i];
		maxS[0][i] = s[i];
		winP[0][i] = w[i];
	}
	winD[0][n] = 0;
	maxS[0][n] = 0;
	winP[0][n] = n;
	loop1(29, x)
	{
		loop(n + 1, i)
		{
			int halfW = winP[x - 1][i];
			winP[x][i] = winP[x - 1][halfW];
			winD[x][i] = winD[x - 1][i] + winD[x - 1][halfW];
			maxS[x][i] = max(maxS[x - 1][i], maxS[x - 1][halfW]);
		}
	}
}

int simulate(signed a, signed b)
{
	int x = a, z = b;
	auto runLosses = [&]() -> int
	{
		while (x != N && z < S[x])
		{
			z += P[x];
			x = L[x];
		}
		if (x == N)
			return z;
		return -1;
	};
	while (winP[0][x] != N)
	{
		rev(30, j)
		{
			if (winP[j][x] != N && z < maxS[j][x])
			{
				z += winD[j][x];
				x = winP[j][x];
			}
		}
		if (z < S[x])
		{
			int res = runLosses();
			if (res != -1)
				return res;
		}
	}
	z += winD[0][x];
	x = winD[0][x];
	return z;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7078 ms 1116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7014 ms 1116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7014 ms 1116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7014 ms 1116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 7078 ms 1116 KB Time limit exceeded
2 Halted 0 ms 0 KB -