Submission #229859

# Submission time Handle Problem Language Result Execution time Memory
229859 2020-05-06T21:30:57 Z pedroslrey Bootfall (IZhO17_bootfall) C++14
28 / 100
1000 ms 16768 KB
//Bootfall subtask 1

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using pii = pair<int, int>;
using lli = long long int;

#define debug(args...) fprintf(stderr, args)
#define pb push_back
#define fi first
#define se second
#define all(xs) xs.begin(), xs.end()

const int INF = 1e9;

int xs[510];
int dp[510][510*510];

int marc[10010];

void make_dp(int n, int s, int ignore) {
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int x = 0; x <= s; ++x) {
			if (i == ignore) {
				dp[i][x] = dp[i-1][x];
				continue;
			}
			int k = 0;
			if (x - xs[i] >= 0) k = dp[i-1][x - xs[i]];
			dp[i][x] = dp[i-1][x] || k;
		}
	}
}

void solve(int n) {
	int s = 0;
	for (int i = 1; i <= n; ++i)
		s += xs[i];

	make_dp(n, s, 0);
	if (!dp[n][s/2] || s%2 == 1) {
		printf("0\n");
		return;
	}

	for (int i = 1; i <= n; ++i) {
		make_dp(n, s, i);
		for (int k = 1; k <= s; ++k) {
			if ((s - xs[i] + k)%2 == 1) marc[k] = 0;
			if (dp[n][((s - xs[i] + k)/2 - k)]) ++marc[k];
		}
	}

	vector<int> ans;
	for (int k = 1; k <= s; ++k) 
		if (marc[k] == n) ans.pb(k);

	printf("%d\n", (int) ans.size());
	for (int a: ans) 
		printf("%d ", a);
	printf("\n");
}

int main() {
	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; ++i)
		scanf("%d", &xs[i]);

	solve(n);
}

Compilation message

bootfall.cpp:4:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
bootfall.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
bootfall.cpp: In function 'int main()':
bootfall.cpp:73:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
bootfall.cpp:76:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &xs[i]);
   ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 640 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 640 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 640 KB Output is correct
21 Correct 29 ms 1536 KB Output is correct
22 Correct 40 ms 2040 KB Output is correct
23 Correct 15 ms 1152 KB Output is correct
24 Correct 76 ms 2816 KB Output is correct
25 Correct 143 ms 4352 KB Output is correct
26 Correct 172 ms 4856 KB Output is correct
27 Correct 162 ms 4608 KB Output is correct
28 Correct 171 ms 4736 KB Output is correct
29 Correct 174 ms 5024 KB Output is correct
30 Correct 104 ms 3192 KB Output is correct
31 Correct 136 ms 4096 KB Output is correct
32 Correct 91 ms 2944 KB Output is correct
33 Correct 184 ms 4992 KB Output is correct
34 Correct 179 ms 5040 KB Output is correct
35 Correct 184 ms 4992 KB Output is correct
36 Correct 86 ms 2944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 640 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 640 KB Output is correct
21 Correct 29 ms 1536 KB Output is correct
22 Correct 40 ms 2040 KB Output is correct
23 Correct 15 ms 1152 KB Output is correct
24 Correct 76 ms 2816 KB Output is correct
25 Correct 143 ms 4352 KB Output is correct
26 Correct 172 ms 4856 KB Output is correct
27 Correct 162 ms 4608 KB Output is correct
28 Correct 171 ms 4736 KB Output is correct
29 Correct 174 ms 5024 KB Output is correct
30 Correct 104 ms 3192 KB Output is correct
31 Correct 136 ms 4096 KB Output is correct
32 Correct 91 ms 2944 KB Output is correct
33 Correct 184 ms 4992 KB Output is correct
34 Correct 179 ms 5040 KB Output is correct
35 Correct 184 ms 4992 KB Output is correct
36 Correct 86 ms 2944 KB Output is correct
37 Execution timed out 1093 ms 16768 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 640 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 640 KB Output is correct
21 Correct 29 ms 1536 KB Output is correct
22 Correct 40 ms 2040 KB Output is correct
23 Correct 15 ms 1152 KB Output is correct
24 Correct 76 ms 2816 KB Output is correct
25 Correct 143 ms 4352 KB Output is correct
26 Correct 172 ms 4856 KB Output is correct
27 Correct 162 ms 4608 KB Output is correct
28 Correct 171 ms 4736 KB Output is correct
29 Correct 174 ms 5024 KB Output is correct
30 Correct 104 ms 3192 KB Output is correct
31 Correct 136 ms 4096 KB Output is correct
32 Correct 91 ms 2944 KB Output is correct
33 Correct 184 ms 4992 KB Output is correct
34 Correct 179 ms 5040 KB Output is correct
35 Correct 184 ms 4992 KB Output is correct
36 Correct 86 ms 2944 KB Output is correct
37 Execution timed out 1093 ms 16768 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 6 ms 640 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 5 ms 640 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 512 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 5 ms 512 KB Output is correct
20 Correct 5 ms 640 KB Output is correct
21 Correct 29 ms 1536 KB Output is correct
22 Correct 40 ms 2040 KB Output is correct
23 Correct 15 ms 1152 KB Output is correct
24 Correct 76 ms 2816 KB Output is correct
25 Correct 143 ms 4352 KB Output is correct
26 Correct 172 ms 4856 KB Output is correct
27 Correct 162 ms 4608 KB Output is correct
28 Correct 171 ms 4736 KB Output is correct
29 Correct 174 ms 5024 KB Output is correct
30 Correct 104 ms 3192 KB Output is correct
31 Correct 136 ms 4096 KB Output is correct
32 Correct 91 ms 2944 KB Output is correct
33 Correct 184 ms 4992 KB Output is correct
34 Correct 179 ms 5040 KB Output is correct
35 Correct 184 ms 4992 KB Output is correct
36 Correct 86 ms 2944 KB Output is correct
37 Execution timed out 1093 ms 16768 KB Time limit exceeded
38 Halted 0 ms 0 KB -