Submission #651435

# Submission time Handle Problem Language Result Execution time Memory
651435 2022-10-18T18:11:21 Z rainboy Broken Device 2 (JOI22_device2) C++17
100 / 100
78 ms 2928 KB
/* https://www.ioi-jp.org/camp/2022/2022-sp-tasks/contest3/device2-review.pdf */
/* https://oj.uz/submission/544506 */
#include "Anna.h"
#include <assert.h>
#include <vector>

using namespace std;

typedef vector<int> vi;

const long long N = 1000000000000000000LL;
const int L = 140;

namespace {
	long long dp[L + 1];
}

int Declare() {
	dp[1] = 1, dp[2] = 1, dp[3] = 2;
	for (int l = 4; l <= L; l++)
		dp[l] = dp[l - 3] + dp[l - 2] + 1;
	long long n = 0;
	for (int l = 1; l <= L; l++)
		n += dp[l] * 2;
	assert(n > N);
	return L;
}

pair<vi, vi> Anna(long long x) {
	x--;
	int a = x % 2;
	x /= 2;
	int l = 1;
	while (x >= dp[l])
		x -= dp[l++];
	vi aa(l, 0), bb(l, 0);
	for (int i = 0; i < l; i++)
		aa[i] = (a + i) % 2;
	bb[0] = a;
	int i = 1;
	while (i < l)
		if (x == 0)
			bb[i] = bb[i - 1] ^ 1, i++;
		else if (x <= dp[l - i - 1])
			x--, bb[i] = bb[i + 1] = bb[i - 1], i += 2;
		else
			x -= dp[l - i - 1] + 1, bb[i] = bb[i + 1] = bb[i + 2] = bb[i - 1] ^ 1, i += 3;
	return make_pair(aa, bb);
}
/* https://www.ioi-jp.org/camp/2022/2022-sp-tasks/contest3/device2-review.pdf */
/* https://oj.uz/submission/544506 */
#include "Bruno.h"
#include <assert.h>
#include <vector>

using namespace std;

typedef vector<int> vi;

const long long N = 1000000000000000000LL;
const int L = 140;

namespace {
	long long dp[L + 1];
	bool init = false;
}

long long Bruno(vi cc) {
	if (!init) {
		init = true;
		dp[1] = 1, dp[2] = 1, dp[3] = 2;
		for (int l = 4; l <= L; l++)
			dp[l] = dp[l - 3] + dp[l - 2] + 1;
		long long n = 0;
		for (int l = 1; l <= L; l++)
			n += dp[l] * 2;
		assert(n > N);
	}
	int l = cc.size() / 2;
	long long x = 1;
	for (int l_ = 1; l_ < l; l_++)
		x += dp[l_] * 2;
	if (cc[0] == 1) {
		for (int i = 0; i < l * 2; i++)
			cc[i] ^= 1;
		x++;
	}
	int d = 0, c = 0;
	for (int i = 1, j = 1; j < l * 2; j++) {
		if (cc[j] == 0)
			d++;
		else
			d--;
		if (d >= 2) {
			if (c == 0)
				x += 2, i += 2;
			else
				x += (dp[l - i - 1] + 1) * 2, i += 3, c = 0;
			d = 0;
		} else if (d <= -2) {
			if (c == 1)
				x += 2, i += 2;
			else
				x += (dp[l - i - 1] + 1) * 2, i += 3, c = 1;
			d = 0;
		}
	}
	return x;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 15 ms 796 KB Output is correct
3 Correct 15 ms 928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 15 ms 796 KB Output is correct
3 Correct 15 ms 928 KB Output is correct
4 Correct 26 ms 1380 KB Output is correct
5 Correct 27 ms 1224 KB Output is correct
6 Correct 26 ms 1312 KB Output is correct
7 Correct 33 ms 1292 KB Output is correct
8 Correct 27 ms 1308 KB Output is correct
9 Correct 27 ms 1340 KB Output is correct
10 Correct 26 ms 1352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 15 ms 796 KB Output is correct
3 Correct 15 ms 928 KB Output is correct
4 Correct 26 ms 1380 KB Output is correct
5 Correct 27 ms 1224 KB Output is correct
6 Correct 26 ms 1312 KB Output is correct
7 Correct 33 ms 1292 KB Output is correct
8 Correct 27 ms 1308 KB Output is correct
9 Correct 27 ms 1340 KB Output is correct
10 Correct 26 ms 1352 KB Output is correct
11 Correct 27 ms 1268 KB Output is correct
12 Correct 28 ms 1256 KB Output is correct
13 Correct 28 ms 1260 KB Output is correct
14 Correct 30 ms 1348 KB Output is correct
15 Correct 31 ms 1244 KB Output is correct
16 Correct 28 ms 1316 KB Output is correct
17 Correct 30 ms 1340 KB Output is correct
18 Correct 27 ms 1168 KB Output is correct
19 Correct 26 ms 1288 KB Output is correct
20 Correct 24 ms 1168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 15 ms 796 KB Output is correct
3 Correct 15 ms 928 KB Output is correct
4 Correct 26 ms 1380 KB Output is correct
5 Correct 27 ms 1224 KB Output is correct
6 Correct 26 ms 1312 KB Output is correct
7 Correct 33 ms 1292 KB Output is correct
8 Correct 27 ms 1308 KB Output is correct
9 Correct 27 ms 1340 KB Output is correct
10 Correct 26 ms 1352 KB Output is correct
11 Correct 27 ms 1268 KB Output is correct
12 Correct 28 ms 1256 KB Output is correct
13 Correct 28 ms 1260 KB Output is correct
14 Correct 30 ms 1348 KB Output is correct
15 Correct 31 ms 1244 KB Output is correct
16 Correct 28 ms 1316 KB Output is correct
17 Correct 30 ms 1340 KB Output is correct
18 Correct 27 ms 1168 KB Output is correct
19 Correct 26 ms 1288 KB Output is correct
20 Correct 24 ms 1168 KB Output is correct
21 Correct 31 ms 1444 KB Output is correct
22 Correct 31 ms 1408 KB Output is correct
23 Correct 33 ms 1452 KB Output is correct
24 Correct 34 ms 1420 KB Output is correct
25 Correct 32 ms 1464 KB Output is correct
26 Correct 34 ms 1476 KB Output is correct
27 Correct 31 ms 1520 KB Output is correct
28 Correct 30 ms 1244 KB Output is correct
29 Correct 31 ms 1252 KB Output is correct
30 Correct 30 ms 1424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 15 ms 796 KB Output is correct
3 Correct 15 ms 928 KB Output is correct
4 Correct 26 ms 1380 KB Output is correct
5 Correct 27 ms 1224 KB Output is correct
6 Correct 26 ms 1312 KB Output is correct
7 Correct 33 ms 1292 KB Output is correct
8 Correct 27 ms 1308 KB Output is correct
9 Correct 27 ms 1340 KB Output is correct
10 Correct 26 ms 1352 KB Output is correct
11 Correct 27 ms 1268 KB Output is correct
12 Correct 28 ms 1256 KB Output is correct
13 Correct 28 ms 1260 KB Output is correct
14 Correct 30 ms 1348 KB Output is correct
15 Correct 31 ms 1244 KB Output is correct
16 Correct 28 ms 1316 KB Output is correct
17 Correct 30 ms 1340 KB Output is correct
18 Correct 27 ms 1168 KB Output is correct
19 Correct 26 ms 1288 KB Output is correct
20 Correct 24 ms 1168 KB Output is correct
21 Correct 31 ms 1444 KB Output is correct
22 Correct 31 ms 1408 KB Output is correct
23 Correct 33 ms 1452 KB Output is correct
24 Correct 34 ms 1420 KB Output is correct
25 Correct 32 ms 1464 KB Output is correct
26 Correct 34 ms 1476 KB Output is correct
27 Correct 31 ms 1520 KB Output is correct
28 Correct 30 ms 1244 KB Output is correct
29 Correct 31 ms 1252 KB Output is correct
30 Correct 30 ms 1424 KB Output is correct
31 Correct 50 ms 1800 KB Output is correct
32 Correct 46 ms 1948 KB Output is correct
33 Correct 53 ms 1908 KB Output is correct
34 Correct 60 ms 1760 KB Output is correct
35 Correct 43 ms 1864 KB Output is correct
36 Correct 43 ms 1904 KB Output is correct
37 Correct 40 ms 1812 KB Output is correct
38 Correct 39 ms 1756 KB Output is correct
39 Correct 44 ms 1796 KB Output is correct
40 Correct 38 ms 1856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 2712 KB Output is correct
2 Correct 78 ms 2704 KB Output is correct
3 Correct 69 ms 2696 KB Output is correct
4 Correct 67 ms 2928 KB Output is correct
5 Correct 74 ms 2760 KB Output is correct
6 Correct 69 ms 2792 KB Output is correct
7 Correct 69 ms 2772 KB Output is correct
8 Correct 66 ms 2680 KB Output is correct
9 Correct 66 ms 2876 KB Output is correct
10 Correct 69 ms 2820 KB Output is correct
11 Correct 70 ms 2888 KB Output is correct
12 Correct 66 ms 2696 KB Output is correct
13 Correct 74 ms 2888 KB Output is correct
14 Correct 63 ms 2860 KB Output is correct
15 Correct 60 ms 2604 KB Output is correct
16 Correct 59 ms 2620 KB Output is correct
17 Correct 56 ms 2660 KB Output is correct
18 Correct 62 ms 2684 KB Output is correct
19 Correct 62 ms 2792 KB Output is correct
20 Correct 62 ms 2656 KB Output is correct