Submission #439258

# Submission time Handle Problem Language Result Execution time Memory
439258 2021-06-29T12:54:40 Z LastRonin Bootfall (IZhO17_bootfall) C++14
100 / 100
397 ms 3524 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 + 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];
ll dp[N * N];

void add(ll x) {
	for(int i = sum + x; i >= x; i--)
		dp[i] += dp[i - x];
	sum += x;
}

void del(ll x) {
	for(int i = 0; i <= sum - x; i++) 
		dp[i + x] -= dp[i];
	sum -= x;	
}
bitset<N * N> x, ans, tr;

int main() {
	speed;
	cin >> n;
	dp[0] = 1ll;
	for(int i = 1; i <= n; i++)
		cin >> a[i], add(a[i]);
	for(int i = 1; i <= sum; i++)
		ans[i] = 1;
	if(sum % 2 != 0 || !dp[sum/2])
		cout << 0, ex;
	for(int i = 1; i <= n; i++) {
		tr = 0;
		ll sum2 = sum - a[i];
		del(a[i]);
		for(int j = 1; j <= sum2; j++) {
			if(dp[j]) {
				ll p = sum2 - j;
				ll z = j - p;
				if(z <= 0)continue;
				tr[z] = 1;	
			}
		}
		add(a[i]);
		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 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 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 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 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 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 2 ms 352 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 3 ms 460 KB Output is correct
25 Correct 4 ms 460 KB Output is correct
26 Correct 5 ms 460 KB Output is correct
27 Correct 4 ms 460 KB Output is correct
28 Correct 4 ms 460 KB Output is correct
29 Correct 4 ms 460 KB Output is correct
30 Correct 4 ms 332 KB Output is correct
31 Correct 4 ms 460 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
33 Correct 4 ms 460 KB Output is correct
34 Correct 4 ms 460 KB Output is correct
35 Correct 4 ms 488 KB Output is correct
36 Correct 3 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 2 ms 352 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 3 ms 460 KB Output is correct
25 Correct 4 ms 460 KB Output is correct
26 Correct 5 ms 460 KB Output is correct
27 Correct 4 ms 460 KB Output is correct
28 Correct 4 ms 460 KB Output is correct
29 Correct 4 ms 460 KB Output is correct
30 Correct 4 ms 332 KB Output is correct
31 Correct 4 ms 460 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
33 Correct 4 ms 460 KB Output is correct
34 Correct 4 ms 460 KB Output is correct
35 Correct 4 ms 488 KB Output is correct
36 Correct 3 ms 460 KB Output is correct
37 Correct 15 ms 692 KB Output is correct
38 Correct 16 ms 716 KB Output is correct
39 Correct 40 ms 844 KB Output is correct
40 Correct 31 ms 844 KB Output is correct
41 Correct 52 ms 960 KB Output is correct
42 Correct 30 ms 768 KB Output is correct
43 Correct 46 ms 1200 KB Output is correct
44 Correct 49 ms 1100 KB Output is correct
45 Correct 48 ms 1124 KB Output is correct
46 Correct 26 ms 656 KB Output is correct
47 Correct 29 ms 788 KB Output is correct
48 Correct 49 ms 1136 KB Output is correct
49 Correct 46 ms 868 KB Output is correct
50 Correct 30 ms 844 KB Output is correct
51 Correct 3 ms 588 KB Output is correct
52 Correct 62 ms 1332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 2 ms 352 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 3 ms 460 KB Output is correct
25 Correct 4 ms 460 KB Output is correct
26 Correct 5 ms 460 KB Output is correct
27 Correct 4 ms 460 KB Output is correct
28 Correct 4 ms 460 KB Output is correct
29 Correct 4 ms 460 KB Output is correct
30 Correct 4 ms 332 KB Output is correct
31 Correct 4 ms 460 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
33 Correct 4 ms 460 KB Output is correct
34 Correct 4 ms 460 KB Output is correct
35 Correct 4 ms 488 KB Output is correct
36 Correct 3 ms 460 KB Output is correct
37 Correct 15 ms 692 KB Output is correct
38 Correct 16 ms 716 KB Output is correct
39 Correct 40 ms 844 KB Output is correct
40 Correct 31 ms 844 KB Output is correct
41 Correct 52 ms 960 KB Output is correct
42 Correct 30 ms 768 KB Output is correct
43 Correct 46 ms 1200 KB Output is correct
44 Correct 49 ms 1100 KB Output is correct
45 Correct 48 ms 1124 KB Output is correct
46 Correct 26 ms 656 KB Output is correct
47 Correct 29 ms 788 KB Output is correct
48 Correct 49 ms 1136 KB Output is correct
49 Correct 46 ms 868 KB Output is correct
50 Correct 30 ms 844 KB Output is correct
51 Correct 3 ms 588 KB Output is correct
52 Correct 62 ms 1332 KB Output is correct
53 Correct 48 ms 1000 KB Output is correct
54 Correct 65 ms 1220 KB Output is correct
55 Correct 126 ms 1780 KB Output is correct
56 Correct 70 ms 1220 KB Output is correct
57 Correct 132 ms 1964 KB Output is correct
58 Correct 72 ms 1268 KB Output is correct
59 Correct 93 ms 1388 KB Output is correct
60 Correct 8 ms 716 KB Output is correct
61 Correct 104 ms 1588 KB Output is correct
62 Correct 120 ms 1664 KB Output is correct
63 Correct 115 ms 1720 KB Output is correct
64 Correct 109 ms 1708 KB Output is correct
65 Correct 48 ms 776 KB Output is correct
66 Correct 44 ms 836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 2 ms 352 KB Output is correct
23 Correct 2 ms 332 KB Output is correct
24 Correct 3 ms 460 KB Output is correct
25 Correct 4 ms 460 KB Output is correct
26 Correct 5 ms 460 KB Output is correct
27 Correct 4 ms 460 KB Output is correct
28 Correct 4 ms 460 KB Output is correct
29 Correct 4 ms 460 KB Output is correct
30 Correct 4 ms 332 KB Output is correct
31 Correct 4 ms 460 KB Output is correct
32 Correct 3 ms 460 KB Output is correct
33 Correct 4 ms 460 KB Output is correct
34 Correct 4 ms 460 KB Output is correct
35 Correct 4 ms 488 KB Output is correct
36 Correct 3 ms 460 KB Output is correct
37 Correct 15 ms 692 KB Output is correct
38 Correct 16 ms 716 KB Output is correct
39 Correct 40 ms 844 KB Output is correct
40 Correct 31 ms 844 KB Output is correct
41 Correct 52 ms 960 KB Output is correct
42 Correct 30 ms 768 KB Output is correct
43 Correct 46 ms 1200 KB Output is correct
44 Correct 49 ms 1100 KB Output is correct
45 Correct 48 ms 1124 KB Output is correct
46 Correct 26 ms 656 KB Output is correct
47 Correct 29 ms 788 KB Output is correct
48 Correct 49 ms 1136 KB Output is correct
49 Correct 46 ms 868 KB Output is correct
50 Correct 30 ms 844 KB Output is correct
51 Correct 3 ms 588 KB Output is correct
52 Correct 62 ms 1332 KB Output is correct
53 Correct 48 ms 1000 KB Output is correct
54 Correct 65 ms 1220 KB Output is correct
55 Correct 126 ms 1780 KB Output is correct
56 Correct 70 ms 1220 KB Output is correct
57 Correct 132 ms 1964 KB Output is correct
58 Correct 72 ms 1268 KB Output is correct
59 Correct 93 ms 1388 KB Output is correct
60 Correct 8 ms 716 KB Output is correct
61 Correct 104 ms 1588 KB Output is correct
62 Correct 120 ms 1664 KB Output is correct
63 Correct 115 ms 1720 KB Output is correct
64 Correct 109 ms 1708 KB Output is correct
65 Correct 48 ms 776 KB Output is correct
66 Correct 44 ms 836 KB Output is correct
67 Correct 106 ms 1480 KB Output is correct
68 Correct 27 ms 1292 KB Output is correct
69 Correct 348 ms 3200 KB Output is correct
70 Correct 217 ms 2120 KB Output is correct
71 Correct 205 ms 2140 KB Output is correct
72 Correct 217 ms 1476 KB Output is correct
73 Correct 200 ms 1292 KB Output is correct
74 Correct 366 ms 3396 KB Output is correct
75 Correct 286 ms 2780 KB Output is correct
76 Correct 382 ms 3456 KB Output is correct
77 Correct 397 ms 3524 KB Output is correct