Submission #1049114

# Submission time Handle Problem Language Result Execution time Memory
1049114 2024-08-08T13:29:09 Z parsadox2 Dungeons Game (IOI21_dungeons) C++17
89 / 100
7000 ms 404304 KB
#include "dungeons.h"
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;

const int N = 4e5 + 10 , Lg = 20;
const long long inf = 1e15 + 10;

int n;

vector <int> s , p , w , l;

long long f(long long x)
{
	if(x <= 0)
		return inf;
	return x;
}

struct item{
	long long mn;
	long long val;
	int id;
};

item a[2 * N][Lg];

item Get(item now , int len)
{
	while(len != 0)
	{
		long long id = now.id , mn = now.mn , val = now.val , dif = val - (val >= s[id]) * s[id];
		bool flg = false;
		for(int i = Lg - 1 ; i >= 0 ; i--)  if((1 << i) <= len && a[id * 2 + (val >= s[id])][i].mn > dif)
		{
			item tmp = a[id * 2 + (val >= s[id])][i];
			now = {min(mn , tmp.mn - dif) , tmp.val + dif , tmp.id};
			len = len - (1 << i);
			flg = true;
			break;
		}
		if(flg)
			continue;
		if(val >= s[id])
		{
			now = {min(mn , f(s[w[id]] - val - s[id])) , val + s[id] , w[id]};
			len--;
		}
		else
		{
			now = {min(mn , f(s[l[id]] - val - p[id])) , val + p[id] , l[id]};
			len--;
		}
	}
	return now;
}

void init(int nn, vector<int> ss, vector<int> pp, vector<int> ww, vector<int> ll) {
	n = nn;
	s = ss;
	p = pp;
	w = ww;
	l = ll;
	s.push_back(0);
	p.push_back(0);
	w.push_back(n);
	l.push_back(n);
	for(int i = 0 ; i <= n ; i++)
	{
		a[i << 1][0] = {f(s[l[i]] - p[i]) , p[i] , l[i]};
		a[(i << 1) + 1][0] = {f(s[w[i]] - 2 * s[i]) , 2 * s[i] , w[i]};
	}
	for(int j = 1 ; j < Lg ; j++)  for(int i = 0 ; i <= 2 * n + 1 ; i++)
	{
		a[i][j] = Get(a[i][j - 1] , (1 << (j - 1)));
	}
}

long long simulate(int x, int z) {
	item tmp = Get({inf , z , x} , 2e7);
	return tmp.val;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 3 ms 2648 KB Output is correct
4 Correct 61 ms 50868 KB Output is correct
5 Correct 2 ms 2652 KB Output is correct
6 Correct 75 ms 50920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 4341 ms 397960 KB Output is correct
3 Correct 4600 ms 401304 KB Output is correct
4 Correct 4002 ms 403492 KB Output is correct
5 Correct 673 ms 402232 KB Output is correct
6 Correct 3876 ms 400220 KB Output is correct
7 Correct 2186 ms 399196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 73 ms 50768 KB Output is correct
3 Correct 75 ms 50944 KB Output is correct
4 Correct 75 ms 51528 KB Output is correct
5 Correct 79 ms 51684 KB Output is correct
6 Correct 90 ms 51672 KB Output is correct
7 Correct 84 ms 51712 KB Output is correct
8 Correct 74 ms 51532 KB Output is correct
9 Correct 76 ms 51784 KB Output is correct
10 Correct 74 ms 51320 KB Output is correct
11 Correct 76 ms 51528 KB Output is correct
12 Correct 140 ms 51788 KB Output is correct
13 Correct 140 ms 51788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 73 ms 50768 KB Output is correct
3 Correct 75 ms 50944 KB Output is correct
4 Correct 75 ms 51528 KB Output is correct
5 Correct 79 ms 51684 KB Output is correct
6 Correct 90 ms 51672 KB Output is correct
7 Correct 84 ms 51712 KB Output is correct
8 Correct 74 ms 51532 KB Output is correct
9 Correct 76 ms 51784 KB Output is correct
10 Correct 74 ms 51320 KB Output is correct
11 Correct 76 ms 51528 KB Output is correct
12 Correct 140 ms 51788 KB Output is correct
13 Correct 140 ms 51788 KB Output is correct
14 Correct 2 ms 2648 KB Output is correct
15 Correct 119 ms 51420 KB Output is correct
16 Correct 83 ms 51680 KB Output is correct
17 Correct 89 ms 51624 KB Output is correct
18 Correct 96 ms 51452 KB Output is correct
19 Correct 94 ms 51528 KB Output is correct
20 Correct 196 ms 51524 KB Output is correct
21 Correct 154 ms 51532 KB Output is correct
22 Correct 124 ms 51776 KB Output is correct
23 Correct 77 ms 51752 KB Output is correct
24 Correct 151 ms 51776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 73 ms 50768 KB Output is correct
3 Correct 75 ms 50944 KB Output is correct
4 Correct 75 ms 51528 KB Output is correct
5 Correct 79 ms 51684 KB Output is correct
6 Correct 90 ms 51672 KB Output is correct
7 Correct 84 ms 51712 KB Output is correct
8 Correct 74 ms 51532 KB Output is correct
9 Correct 76 ms 51784 KB Output is correct
10 Correct 74 ms 51320 KB Output is correct
11 Correct 76 ms 51528 KB Output is correct
12 Correct 140 ms 51788 KB Output is correct
13 Correct 140 ms 51788 KB Output is correct
14 Correct 2 ms 2648 KB Output is correct
15 Correct 119 ms 51420 KB Output is correct
16 Correct 83 ms 51680 KB Output is correct
17 Correct 89 ms 51624 KB Output is correct
18 Correct 96 ms 51452 KB Output is correct
19 Correct 94 ms 51528 KB Output is correct
20 Correct 196 ms 51524 KB Output is correct
21 Correct 154 ms 51532 KB Output is correct
22 Correct 124 ms 51776 KB Output is correct
23 Correct 77 ms 51752 KB Output is correct
24 Correct 151 ms 51776 KB Output is correct
25 Correct 56 ms 51152 KB Output is correct
26 Correct 84 ms 51604 KB Output is correct
27 Correct 191 ms 51532 KB Output is correct
28 Correct 155 ms 51596 KB Output is correct
29 Correct 81 ms 51784 KB Output is correct
30 Correct 258 ms 51532 KB Output is correct
31 Correct 344 ms 51776 KB Output is correct
32 Correct 386 ms 51784 KB Output is correct
33 Correct 119 ms 51760 KB Output is correct
34 Correct 128 ms 51788 KB Output is correct
35 Correct 276 ms 51740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 4341 ms 397960 KB Output is correct
3 Correct 4600 ms 401304 KB Output is correct
4 Correct 4002 ms 403492 KB Output is correct
5 Correct 673 ms 402232 KB Output is correct
6 Correct 3876 ms 400220 KB Output is correct
7 Correct 2186 ms 399196 KB Output is correct
8 Correct 2 ms 2652 KB Output is correct
9 Correct 73 ms 50768 KB Output is correct
10 Correct 75 ms 50944 KB Output is correct
11 Correct 75 ms 51528 KB Output is correct
12 Correct 79 ms 51684 KB Output is correct
13 Correct 90 ms 51672 KB Output is correct
14 Correct 84 ms 51712 KB Output is correct
15 Correct 74 ms 51532 KB Output is correct
16 Correct 76 ms 51784 KB Output is correct
17 Correct 74 ms 51320 KB Output is correct
18 Correct 76 ms 51528 KB Output is correct
19 Correct 140 ms 51788 KB Output is correct
20 Correct 140 ms 51788 KB Output is correct
21 Correct 2 ms 2648 KB Output is correct
22 Correct 119 ms 51420 KB Output is correct
23 Correct 83 ms 51680 KB Output is correct
24 Correct 89 ms 51624 KB Output is correct
25 Correct 96 ms 51452 KB Output is correct
26 Correct 94 ms 51528 KB Output is correct
27 Correct 196 ms 51524 KB Output is correct
28 Correct 154 ms 51532 KB Output is correct
29 Correct 124 ms 51776 KB Output is correct
30 Correct 77 ms 51752 KB Output is correct
31 Correct 151 ms 51776 KB Output is correct
32 Correct 56 ms 51152 KB Output is correct
33 Correct 84 ms 51604 KB Output is correct
34 Correct 191 ms 51532 KB Output is correct
35 Correct 155 ms 51596 KB Output is correct
36 Correct 81 ms 51784 KB Output is correct
37 Correct 258 ms 51532 KB Output is correct
38 Correct 344 ms 51776 KB Output is correct
39 Correct 386 ms 51784 KB Output is correct
40 Correct 119 ms 51760 KB Output is correct
41 Correct 128 ms 51788 KB Output is correct
42 Correct 276 ms 51740 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 2 ms 2652 KB Output is correct
45 Correct 699 ms 404304 KB Output is correct
46 Correct 2149 ms 399780 KB Output is correct
47 Correct 1370 ms 400864 KB Output is correct
48 Correct 3018 ms 402136 KB Output is correct
49 Correct 705 ms 401884 KB Output is correct
50 Correct 3687 ms 402652 KB Output is correct
51 Correct 809 ms 401252 KB Output is correct
52 Correct 3989 ms 400736 KB Output is correct
53 Execution timed out 7041 ms 400780 KB Time limit exceeded
54 Halted 0 ms 0 KB -