Submission #655898

# Submission time Handle Problem Language Result Execution time Memory
655898 2022-11-06T01:31:21 Z gs12117 Broken Device 2 (JOI22_device2) C++17
40 / 100
76 ms 2936 KB
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <random>

int Declare() {
	int max_m = 139;
	return max_m;
}

std::pair<std::vector<int>, std::vector<int> > Anna(long long A) {
	int max_m = 139;
	long long int dp[200];
	for (int i = 0; i < max_m; i++) {
		if (i < 5)dp[i] = i + 1;
		else dp[i] = dp[i - 2] + dp[i - 3];
	}
	int sz = 0;
	for (int i = max_m - 3; i >= 0; i--) {
		if (A < dp[i] * 4) {
			sz = i;
			break;
		}
		A -= dp[i] * 4;
	}
	int invt = 0;
	if (A >= dp[sz] * 2) {
		A -= dp[sz] * 2;
		invt = 1;
	}
	std::vector<int> X;
	std::vector<int> Y;
	for (int i = 0; i < sz + 3; i++) {
		Y.push_back((sz + i) % 2); // last Y[sz+2]=0
	}
	if (A >= dp[sz]) {
		A -= dp[sz];
		X.push_back(1);
		X.push_back(1);
	}
	else {
		X.push_back(0);
		X.push_back(0);
	}
	int p = sz;
	while (1) {
		if (p < 5) {
			for (int i = 0; i < p; i++) {
				if (i < A)X.push_back(1);
				else X.push_back(0);
			}
			break;
		}
		else {
			if (A >= dp[p - 2]) {
				A -= dp[p - 2];
				X.push_back(1 - X[X.size() - 1]);
				p--;
			}
			X.push_back(X[X.size() - 1]);
			X.push_back(X[X.size() - 1]);
			p -= 2;
		}
	}
	X.push_back(0);
	if (invt == 1) {
		for (int i = 0; i < sz + 3; i++) {
			X[i] = 1 - X[i];
			Y[i] = 1 - Y[i];
		}
	}
	return make_pair(X, Y);
}
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <random>

long long Bruno(std::vector<int> u) {
	int max_m = 139;
	long long int dp[200];
	for (int i = 0; i < max_m; i++) {
		if (i < 5)dp[i] = i + 1;
		else dp[i] = dp[i - 2] + dp[i - 3];
	}
	int sz = u.size() / 2 - 3;
	long long int ans = 0;
	for (int i = max_m - 3; i >= 0; i--) {
		if (i == sz) {
			break;
		}
		ans += dp[i] * 4;
	}
	std::vector<int> v = u;
	if (u[u.size() - 1] == 1) {
		ans += dp[sz] * 2;
		for (int i = 0; i < v.size(); i++) {
			v[i] = 1 - v[i];
		}
	}
	int sumv = 0;
	for (int i = 0; i < v.size(); i++) {
		sumv += v[i];
	}
	sumv -= (sz + 3) / 2;
	int curmax = 0;
	int curmin = 0;
	int curv = 0;
	if (sz % 2 == 1) {
		curmax = 1;
	}
	else {
		curmin = -1;
	}
	int p = 0;
	for (; p < v.size();) {
		curv += 2 * v[p] - 1;
		p++;
		if (curv > curmax || curv < curmin) {
			break;
		}
	}
	int lastv = 0;
	int szleft = sz;
	if (curv > curmax) {
		ans += dp[sz];
		lastv = 1;
	}
	curmax = curv + 1;
	curmin = curv - 1;
	while (szleft >= 5) {
		curv += 2 * v[p] - 1;
		p++;
		if (curv > curmax) {
			if (lastv == 0) {
				ans += dp[szleft - 2];
				szleft--;
				sumv--;
			}
			lastv = 1;
			curmax = curv + 1;
			curmin = curv - 1;
			szleft -= 2;
			sumv -= 2;
		}
		else if (curv < curmin) {
			if (lastv == 1) {
				ans += dp[szleft - 2];
				szleft--;
			}
			lastv = 0;
			curmax = curv + 1;
			curmin = curv - 1;
			szleft -= 2;
		}
	}
	ans += sumv;
	return ans;
}

Compilation message

Bruno.cpp: In function 'long long int Bruno(std::vector<int>)':
Bruno.cpp:24:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for (int i = 0; i < v.size(); i++) {
      |                   ~~^~~~~~~~~~
Bruno.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for (int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
Bruno.cpp:43:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |  for (; p < v.size();) {
      |         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 504 KB Output is correct
2 Correct 64 ms 2712 KB Output is correct
3 Correct 60 ms 2768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 504 KB Output is correct
2 Correct 64 ms 2712 KB Output is correct
3 Correct 60 ms 2768 KB Output is correct
4 Correct 70 ms 2824 KB Output is correct
5 Correct 72 ms 2788 KB Output is correct
6 Correct 60 ms 2876 KB Output is correct
7 Correct 65 ms 2792 KB Output is correct
8 Correct 63 ms 2864 KB Output is correct
9 Correct 61 ms 2660 KB Output is correct
10 Correct 61 ms 2716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 504 KB Output is correct
2 Correct 64 ms 2712 KB Output is correct
3 Correct 60 ms 2768 KB Output is correct
4 Correct 70 ms 2824 KB Output is correct
5 Correct 72 ms 2788 KB Output is correct
6 Correct 60 ms 2876 KB Output is correct
7 Correct 65 ms 2792 KB Output is correct
8 Correct 63 ms 2864 KB Output is correct
9 Correct 61 ms 2660 KB Output is correct
10 Correct 61 ms 2716 KB Output is correct
11 Correct 67 ms 2736 KB Output is correct
12 Correct 64 ms 2804 KB Output is correct
13 Correct 63 ms 2728 KB Output is correct
14 Correct 63 ms 2744 KB Output is correct
15 Correct 61 ms 2780 KB Output is correct
16 Correct 64 ms 2780 KB Output is correct
17 Correct 61 ms 2768 KB Output is correct
18 Correct 71 ms 2668 KB Output is correct
19 Correct 61 ms 2704 KB Output is correct
20 Correct 62 ms 2812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 504 KB Output is correct
2 Correct 64 ms 2712 KB Output is correct
3 Correct 60 ms 2768 KB Output is correct
4 Correct 70 ms 2824 KB Output is correct
5 Correct 72 ms 2788 KB Output is correct
6 Correct 60 ms 2876 KB Output is correct
7 Correct 65 ms 2792 KB Output is correct
8 Correct 63 ms 2864 KB Output is correct
9 Correct 61 ms 2660 KB Output is correct
10 Correct 61 ms 2716 KB Output is correct
11 Correct 67 ms 2736 KB Output is correct
12 Correct 64 ms 2804 KB Output is correct
13 Correct 63 ms 2728 KB Output is correct
14 Correct 63 ms 2744 KB Output is correct
15 Correct 61 ms 2780 KB Output is correct
16 Correct 64 ms 2780 KB Output is correct
17 Correct 61 ms 2768 KB Output is correct
18 Correct 71 ms 2668 KB Output is correct
19 Correct 61 ms 2704 KB Output is correct
20 Correct 62 ms 2812 KB Output is correct
21 Correct 69 ms 2860 KB Output is correct
22 Correct 68 ms 2856 KB Output is correct
23 Correct 62 ms 2692 KB Output is correct
24 Correct 62 ms 2656 KB Output is correct
25 Correct 73 ms 2696 KB Output is correct
26 Correct 61 ms 2760 KB Output is correct
27 Correct 60 ms 2808 KB Output is correct
28 Correct 63 ms 2784 KB Output is correct
29 Correct 62 ms 2628 KB Output is correct
30 Correct 68 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 504 KB Output is correct
2 Correct 64 ms 2712 KB Output is correct
3 Correct 60 ms 2768 KB Output is correct
4 Correct 70 ms 2824 KB Output is correct
5 Correct 72 ms 2788 KB Output is correct
6 Correct 60 ms 2876 KB Output is correct
7 Correct 65 ms 2792 KB Output is correct
8 Correct 63 ms 2864 KB Output is correct
9 Correct 61 ms 2660 KB Output is correct
10 Correct 61 ms 2716 KB Output is correct
11 Correct 67 ms 2736 KB Output is correct
12 Correct 64 ms 2804 KB Output is correct
13 Correct 63 ms 2728 KB Output is correct
14 Correct 63 ms 2744 KB Output is correct
15 Correct 61 ms 2780 KB Output is correct
16 Correct 64 ms 2780 KB Output is correct
17 Correct 61 ms 2768 KB Output is correct
18 Correct 71 ms 2668 KB Output is correct
19 Correct 61 ms 2704 KB Output is correct
20 Correct 62 ms 2812 KB Output is correct
21 Correct 69 ms 2860 KB Output is correct
22 Correct 68 ms 2856 KB Output is correct
23 Correct 62 ms 2692 KB Output is correct
24 Correct 62 ms 2656 KB Output is correct
25 Correct 73 ms 2696 KB Output is correct
26 Correct 61 ms 2760 KB Output is correct
27 Correct 60 ms 2808 KB Output is correct
28 Correct 63 ms 2784 KB Output is correct
29 Correct 62 ms 2628 KB Output is correct
30 Correct 68 ms 2680 KB Output is correct
31 Correct 65 ms 2704 KB Output is correct
32 Correct 69 ms 2936 KB Output is correct
33 Correct 64 ms 2756 KB Output is correct
34 Correct 68 ms 2688 KB Output is correct
35 Correct 63 ms 2692 KB Output is correct
36 Correct 61 ms 2804 KB Output is correct
37 Correct 61 ms 2756 KB Output is correct
38 Correct 63 ms 2848 KB Output is correct
39 Correct 63 ms 2756 KB Output is correct
40 Correct 60 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 2824 KB Output isn't correct
2 Halted 0 ms 0 KB -