Submission #439234

# Submission time Handle Problem Language Result Execution time Memory
439234 2021-06-29T12:09:36 Z LastRonin Bootfall (IZhO17_bootfall) C++14
44 / 100
1000 ms 848 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 = 500 + 10;
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];
	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';	
				
}
/*
*/  
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 472 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 472 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 12 ms 460 KB Output is correct
11 Correct 12 ms 468 KB Output is correct
12 Correct 12 ms 468 KB Output is correct
13 Correct 9 ms 460 KB Output is correct
14 Correct 10 ms 472 KB Output is correct
15 Correct 10 ms 460 KB Output is correct
16 Correct 12 ms 468 KB Output is correct
17 Correct 5 ms 460 KB Output is correct
18 Correct 8 ms 476 KB Output is correct
19 Correct 9 ms 460 KB Output is correct
20 Correct 12 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 472 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 12 ms 460 KB Output is correct
11 Correct 12 ms 468 KB Output is correct
12 Correct 12 ms 468 KB Output is correct
13 Correct 9 ms 460 KB Output is correct
14 Correct 10 ms 472 KB Output is correct
15 Correct 10 ms 460 KB Output is correct
16 Correct 12 ms 468 KB Output is correct
17 Correct 5 ms 460 KB Output is correct
18 Correct 8 ms 476 KB Output is correct
19 Correct 9 ms 460 KB Output is correct
20 Correct 12 ms 460 KB Output is correct
21 Correct 50 ms 460 KB Output is correct
22 Correct 71 ms 460 KB Output is correct
23 Correct 31 ms 464 KB Output is correct
24 Correct 110 ms 460 KB Output is correct
25 Correct 107 ms 460 KB Output is correct
26 Correct 122 ms 468 KB Output is correct
27 Correct 126 ms 460 KB Output is correct
28 Correct 125 ms 580 KB Output is correct
29 Correct 124 ms 460 KB Output is correct
30 Correct 122 ms 460 KB Output is correct
31 Correct 126 ms 464 KB Output is correct
32 Correct 121 ms 460 KB Output is correct
33 Correct 121 ms 460 KB Output is correct
34 Correct 126 ms 460 KB Output is correct
35 Correct 123 ms 460 KB Output is correct
36 Correct 121 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 472 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 12 ms 460 KB Output is correct
11 Correct 12 ms 468 KB Output is correct
12 Correct 12 ms 468 KB Output is correct
13 Correct 9 ms 460 KB Output is correct
14 Correct 10 ms 472 KB Output is correct
15 Correct 10 ms 460 KB Output is correct
16 Correct 12 ms 468 KB Output is correct
17 Correct 5 ms 460 KB Output is correct
18 Correct 8 ms 476 KB Output is correct
19 Correct 9 ms 460 KB Output is correct
20 Correct 12 ms 460 KB Output is correct
21 Correct 50 ms 460 KB Output is correct
22 Correct 71 ms 460 KB Output is correct
23 Correct 31 ms 464 KB Output is correct
24 Correct 110 ms 460 KB Output is correct
25 Correct 107 ms 460 KB Output is correct
26 Correct 122 ms 468 KB Output is correct
27 Correct 126 ms 460 KB Output is correct
28 Correct 125 ms 580 KB Output is correct
29 Correct 124 ms 460 KB Output is correct
30 Correct 122 ms 460 KB Output is correct
31 Correct 126 ms 464 KB Output is correct
32 Correct 121 ms 460 KB Output is correct
33 Correct 121 ms 460 KB Output is correct
34 Correct 126 ms 460 KB Output is correct
35 Correct 123 ms 460 KB Output is correct
36 Correct 121 ms 464 KB Output is correct
37 Correct 480 ms 592 KB Output is correct
38 Correct 481 ms 580 KB Output is correct
39 Correct 749 ms 460 KB Output is correct
40 Correct 895 ms 708 KB Output is correct
41 Correct 896 ms 460 KB Output is correct
42 Correct 754 ms 580 KB Output is correct
43 Correct 731 ms 836 KB Output is correct
44 Correct 762 ms 832 KB Output is correct
45 Correct 767 ms 828 KB Output is correct
46 Correct 864 ms 460 KB Output is correct
47 Correct 747 ms 580 KB Output is correct
48 Correct 770 ms 676 KB Output is correct
49 Correct 765 ms 520 KB Output is correct
50 Correct 763 ms 576 KB Output is correct
51 Correct 1 ms 460 KB Output is correct
52 Correct 903 ms 848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 472 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 12 ms 460 KB Output is correct
11 Correct 12 ms 468 KB Output is correct
12 Correct 12 ms 468 KB Output is correct
13 Correct 9 ms 460 KB Output is correct
14 Correct 10 ms 472 KB Output is correct
15 Correct 10 ms 460 KB Output is correct
16 Correct 12 ms 468 KB Output is correct
17 Correct 5 ms 460 KB Output is correct
18 Correct 8 ms 476 KB Output is correct
19 Correct 9 ms 460 KB Output is correct
20 Correct 12 ms 460 KB Output is correct
21 Correct 50 ms 460 KB Output is correct
22 Correct 71 ms 460 KB Output is correct
23 Correct 31 ms 464 KB Output is correct
24 Correct 110 ms 460 KB Output is correct
25 Correct 107 ms 460 KB Output is correct
26 Correct 122 ms 468 KB Output is correct
27 Correct 126 ms 460 KB Output is correct
28 Correct 125 ms 580 KB Output is correct
29 Correct 124 ms 460 KB Output is correct
30 Correct 122 ms 460 KB Output is correct
31 Correct 126 ms 464 KB Output is correct
32 Correct 121 ms 460 KB Output is correct
33 Correct 121 ms 460 KB Output is correct
34 Correct 126 ms 460 KB Output is correct
35 Correct 123 ms 460 KB Output is correct
36 Correct 121 ms 464 KB Output is correct
37 Correct 480 ms 592 KB Output is correct
38 Correct 481 ms 580 KB Output is correct
39 Correct 749 ms 460 KB Output is correct
40 Correct 895 ms 708 KB Output is correct
41 Correct 896 ms 460 KB Output is correct
42 Correct 754 ms 580 KB Output is correct
43 Correct 731 ms 836 KB Output is correct
44 Correct 762 ms 832 KB Output is correct
45 Correct 767 ms 828 KB Output is correct
46 Correct 864 ms 460 KB Output is correct
47 Correct 747 ms 580 KB Output is correct
48 Correct 770 ms 676 KB Output is correct
49 Correct 765 ms 520 KB Output is correct
50 Correct 763 ms 576 KB Output is correct
51 Correct 1 ms 460 KB Output is correct
52 Correct 903 ms 848 KB Output is correct
53 Execution timed out 1090 ms 460 KB Time limit exceeded
54 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 3 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 472 KB Output is correct
8 Correct 3 ms 460 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 12 ms 460 KB Output is correct
11 Correct 12 ms 468 KB Output is correct
12 Correct 12 ms 468 KB Output is correct
13 Correct 9 ms 460 KB Output is correct
14 Correct 10 ms 472 KB Output is correct
15 Correct 10 ms 460 KB Output is correct
16 Correct 12 ms 468 KB Output is correct
17 Correct 5 ms 460 KB Output is correct
18 Correct 8 ms 476 KB Output is correct
19 Correct 9 ms 460 KB Output is correct
20 Correct 12 ms 460 KB Output is correct
21 Correct 50 ms 460 KB Output is correct
22 Correct 71 ms 460 KB Output is correct
23 Correct 31 ms 464 KB Output is correct
24 Correct 110 ms 460 KB Output is correct
25 Correct 107 ms 460 KB Output is correct
26 Correct 122 ms 468 KB Output is correct
27 Correct 126 ms 460 KB Output is correct
28 Correct 125 ms 580 KB Output is correct
29 Correct 124 ms 460 KB Output is correct
30 Correct 122 ms 460 KB Output is correct
31 Correct 126 ms 464 KB Output is correct
32 Correct 121 ms 460 KB Output is correct
33 Correct 121 ms 460 KB Output is correct
34 Correct 126 ms 460 KB Output is correct
35 Correct 123 ms 460 KB Output is correct
36 Correct 121 ms 464 KB Output is correct
37 Correct 480 ms 592 KB Output is correct
38 Correct 481 ms 580 KB Output is correct
39 Correct 749 ms 460 KB Output is correct
40 Correct 895 ms 708 KB Output is correct
41 Correct 896 ms 460 KB Output is correct
42 Correct 754 ms 580 KB Output is correct
43 Correct 731 ms 836 KB Output is correct
44 Correct 762 ms 832 KB Output is correct
45 Correct 767 ms 828 KB Output is correct
46 Correct 864 ms 460 KB Output is correct
47 Correct 747 ms 580 KB Output is correct
48 Correct 770 ms 676 KB Output is correct
49 Correct 765 ms 520 KB Output is correct
50 Correct 763 ms 576 KB Output is correct
51 Correct 1 ms 460 KB Output is correct
52 Correct 903 ms 848 KB Output is correct
53 Execution timed out 1090 ms 460 KB Time limit exceeded
54 Halted 0 ms 0 KB -