Submission #439237

# Submission time Handle Problem Language Result Execution time Memory
439237 2021-06-29T12:13:27 Z LastRonin Bootfall (IZhO17_bootfall) C++14
65 / 100
818 ms 1012 KB
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0) 
#define sz(a) (a).size()
#define triple pair<pill, ll>
#define pinode pair<node*, node*>
#define quadra pair<pill, pill>
#define ld long double
using namespace std;
 
const ll N = 350 + 1;
const ll M = 1e4 + 10;
const ll big = 1e17;
const ll hsh2 = 1964325029;
const long long mod = 1e9 + 7;
const long double EPS = 1e-10;
const ll block = 1e7;
const ll shift = 2e3;
const ld pi = acos(-1.0);

ll sum = 0;
ll n;
ll a[N];

int main() {
	speed;
	cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; i++)
		cin >> a[i], sum += a[i];
	const ll p = sum + 1;
	bitset<N * N> x, ans, tr;
	for(int i = 1; i <= sum; i++)
		ans[i] = 1;
	if(sum % 2 != 0)
		cout << 0, ex;
   	x = 0;
	x[0] = 1;
	for(int i = 1; i <= n; i++)
		x = x|(x<<a[i]);
	if(!x[sum/2])
		cout << 0, ex;	
	for(int i = 1; i <= n; i++) {
		x = tr = 0;
		x[0] = 1;
		ll sum2 = sum - a[i];
		for(int j = 1; j <= n; j++) 
			if(j != i)
				x = x|(x<<a[j]);
		for(int j = 1; j <= sum2; j++) {
			if(x[j]) {
				ll p = sum2 - j;
				ll z = j - p;
				if(z <= 0)continue;
				tr[z] = 1;	
			}
		}
		ans &= tr;
	}
	vector<int> answ;
	for(int i = 1; i <= sum ; i++)
		if(ans[i])
			answ.pb(i);
	cout << answ.size() << '\n';
	for(auto u : answ)
		cout << u << " ";
	cout << '\n';	
				
}
/*
*/  

Compilation message

bootfall.cpp: In function 'int main()':
bootfall.cpp:43:11: warning: unused variable 'p' [-Wunused-variable]
   43 |  const ll p = sum + 1;
      |           ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 268 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 268 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 7 ms 332 KB Output is correct
11 Correct 6 ms 380 KB Output is correct
12 Correct 8 ms 412 KB Output is correct
13 Correct 5 ms 332 KB Output is correct
14 Correct 6 ms 332 KB Output is correct
15 Correct 5 ms 332 KB Output is correct
16 Correct 6 ms 332 KB Output is correct
17 Correct 3 ms 332 KB Output is correct
18 Correct 4 ms 380 KB Output is correct
19 Correct 5 ms 332 KB Output is correct
20 Correct 6 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 268 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 7 ms 332 KB Output is correct
11 Correct 6 ms 380 KB Output is correct
12 Correct 8 ms 412 KB Output is correct
13 Correct 5 ms 332 KB Output is correct
14 Correct 6 ms 332 KB Output is correct
15 Correct 5 ms 332 KB Output is correct
16 Correct 6 ms 332 KB Output is correct
17 Correct 3 ms 332 KB Output is correct
18 Correct 4 ms 380 KB Output is correct
19 Correct 5 ms 332 KB Output is correct
20 Correct 6 ms 332 KB Output is correct
21 Correct 27 ms 332 KB Output is correct
22 Correct 33 ms 376 KB Output is correct
23 Correct 20 ms 388 KB Output is correct
24 Correct 63 ms 360 KB Output is correct
25 Correct 59 ms 376 KB Output is correct
26 Correct 59 ms 364 KB Output is correct
27 Correct 73 ms 376 KB Output is correct
28 Correct 62 ms 364 KB Output is correct
29 Correct 60 ms 332 KB Output is correct
30 Correct 60 ms 332 KB Output is correct
31 Correct 59 ms 376 KB Output is correct
32 Correct 68 ms 332 KB Output is correct
33 Correct 60 ms 332 KB Output is correct
34 Correct 64 ms 376 KB Output is correct
35 Correct 60 ms 368 KB Output is correct
36 Correct 58 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 268 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 7 ms 332 KB Output is correct
11 Correct 6 ms 380 KB Output is correct
12 Correct 8 ms 412 KB Output is correct
13 Correct 5 ms 332 KB Output is correct
14 Correct 6 ms 332 KB Output is correct
15 Correct 5 ms 332 KB Output is correct
16 Correct 6 ms 332 KB Output is correct
17 Correct 3 ms 332 KB Output is correct
18 Correct 4 ms 380 KB Output is correct
19 Correct 5 ms 332 KB Output is correct
20 Correct 6 ms 332 KB Output is correct
21 Correct 27 ms 332 KB Output is correct
22 Correct 33 ms 376 KB Output is correct
23 Correct 20 ms 388 KB Output is correct
24 Correct 63 ms 360 KB Output is correct
25 Correct 59 ms 376 KB Output is correct
26 Correct 59 ms 364 KB Output is correct
27 Correct 73 ms 376 KB Output is correct
28 Correct 62 ms 364 KB Output is correct
29 Correct 60 ms 332 KB Output is correct
30 Correct 60 ms 332 KB Output is correct
31 Correct 59 ms 376 KB Output is correct
32 Correct 68 ms 332 KB Output is correct
33 Correct 60 ms 332 KB Output is correct
34 Correct 64 ms 376 KB Output is correct
35 Correct 60 ms 368 KB Output is correct
36 Correct 58 ms 332 KB Output is correct
37 Correct 268 ms 504 KB Output is correct
38 Correct 241 ms 492 KB Output is correct
39 Correct 373 ms 364 KB Output is correct
40 Correct 440 ms 496 KB Output is correct
41 Correct 453 ms 364 KB Output is correct
42 Correct 375 ms 504 KB Output is correct
43 Correct 368 ms 744 KB Output is correct
44 Correct 401 ms 836 KB Output is correct
45 Correct 395 ms 748 KB Output is correct
46 Correct 436 ms 360 KB Output is correct
47 Correct 380 ms 620 KB Output is correct
48 Correct 415 ms 620 KB Output is correct
49 Correct 390 ms 368 KB Output is correct
50 Correct 381 ms 580 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 497 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 268 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 7 ms 332 KB Output is correct
11 Correct 6 ms 380 KB Output is correct
12 Correct 8 ms 412 KB Output is correct
13 Correct 5 ms 332 KB Output is correct
14 Correct 6 ms 332 KB Output is correct
15 Correct 5 ms 332 KB Output is correct
16 Correct 6 ms 332 KB Output is correct
17 Correct 3 ms 332 KB Output is correct
18 Correct 4 ms 380 KB Output is correct
19 Correct 5 ms 332 KB Output is correct
20 Correct 6 ms 332 KB Output is correct
21 Correct 27 ms 332 KB Output is correct
22 Correct 33 ms 376 KB Output is correct
23 Correct 20 ms 388 KB Output is correct
24 Correct 63 ms 360 KB Output is correct
25 Correct 59 ms 376 KB Output is correct
26 Correct 59 ms 364 KB Output is correct
27 Correct 73 ms 376 KB Output is correct
28 Correct 62 ms 364 KB Output is correct
29 Correct 60 ms 332 KB Output is correct
30 Correct 60 ms 332 KB Output is correct
31 Correct 59 ms 376 KB Output is correct
32 Correct 68 ms 332 KB Output is correct
33 Correct 60 ms 332 KB Output is correct
34 Correct 64 ms 376 KB Output is correct
35 Correct 60 ms 368 KB Output is correct
36 Correct 58 ms 332 KB Output is correct
37 Correct 268 ms 504 KB Output is correct
38 Correct 241 ms 492 KB Output is correct
39 Correct 373 ms 364 KB Output is correct
40 Correct 440 ms 496 KB Output is correct
41 Correct 453 ms 364 KB Output is correct
42 Correct 375 ms 504 KB Output is correct
43 Correct 368 ms 744 KB Output is correct
44 Correct 401 ms 836 KB Output is correct
45 Correct 395 ms 748 KB Output is correct
46 Correct 436 ms 360 KB Output is correct
47 Correct 380 ms 620 KB Output is correct
48 Correct 415 ms 620 KB Output is correct
49 Correct 390 ms 368 KB Output is correct
50 Correct 381 ms 580 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 497 ms 744 KB Output is correct
53 Correct 550 ms 620 KB Output is correct
54 Correct 790 ms 756 KB Output is correct
55 Correct 802 ms 880 KB Output is correct
56 Correct 607 ms 752 KB Output is correct
57 Correct 818 ms 1012 KB Output is correct
58 Correct 781 ms 748 KB Output is correct
59 Correct 795 ms 840 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 758 ms 892 KB Output is correct
62 Correct 662 ms 884 KB Output is correct
63 Correct 680 ms 884 KB Output is correct
64 Correct 643 ms 884 KB Output is correct
65 Correct 602 ms 332 KB Output is correct
66 Correct 590 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 268 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 7 ms 332 KB Output is correct
11 Correct 6 ms 380 KB Output is correct
12 Correct 8 ms 412 KB Output is correct
13 Correct 5 ms 332 KB Output is correct
14 Correct 6 ms 332 KB Output is correct
15 Correct 5 ms 332 KB Output is correct
16 Correct 6 ms 332 KB Output is correct
17 Correct 3 ms 332 KB Output is correct
18 Correct 4 ms 380 KB Output is correct
19 Correct 5 ms 332 KB Output is correct
20 Correct 6 ms 332 KB Output is correct
21 Correct 27 ms 332 KB Output is correct
22 Correct 33 ms 376 KB Output is correct
23 Correct 20 ms 388 KB Output is correct
24 Correct 63 ms 360 KB Output is correct
25 Correct 59 ms 376 KB Output is correct
26 Correct 59 ms 364 KB Output is correct
27 Correct 73 ms 376 KB Output is correct
28 Correct 62 ms 364 KB Output is correct
29 Correct 60 ms 332 KB Output is correct
30 Correct 60 ms 332 KB Output is correct
31 Correct 59 ms 376 KB Output is correct
32 Correct 68 ms 332 KB Output is correct
33 Correct 60 ms 332 KB Output is correct
34 Correct 64 ms 376 KB Output is correct
35 Correct 60 ms 368 KB Output is correct
36 Correct 58 ms 332 KB Output is correct
37 Correct 268 ms 504 KB Output is correct
38 Correct 241 ms 492 KB Output is correct
39 Correct 373 ms 364 KB Output is correct
40 Correct 440 ms 496 KB Output is correct
41 Correct 453 ms 364 KB Output is correct
42 Correct 375 ms 504 KB Output is correct
43 Correct 368 ms 744 KB Output is correct
44 Correct 401 ms 836 KB Output is correct
45 Correct 395 ms 748 KB Output is correct
46 Correct 436 ms 360 KB Output is correct
47 Correct 380 ms 620 KB Output is correct
48 Correct 415 ms 620 KB Output is correct
49 Correct 390 ms 368 KB Output is correct
50 Correct 381 ms 580 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 497 ms 744 KB Output is correct
53 Correct 550 ms 620 KB Output is correct
54 Correct 790 ms 756 KB Output is correct
55 Correct 802 ms 880 KB Output is correct
56 Correct 607 ms 752 KB Output is correct
57 Correct 818 ms 1012 KB Output is correct
58 Correct 781 ms 748 KB Output is correct
59 Correct 795 ms 840 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 758 ms 892 KB Output is correct
62 Correct 662 ms 884 KB Output is correct
63 Correct 680 ms 884 KB Output is correct
64 Correct 643 ms 884 KB Output is correct
65 Correct 602 ms 332 KB Output is correct
66 Correct 590 ms 436 KB Output is correct
67 Incorrect 1 ms 332 KB Output isn't correct
68 Halted 0 ms 0 KB -