Submission #377084

# Submission time Handle Problem Language Result Execution time Memory
377084 2021-03-13T01:36:22 Z ijxjdjd Bootfall (IZhO17_bootfall) C++14
100 / 100
128 ms 33896 KB
#include <bits/stdc++.h>
#define FR(i, N) for (int i = 0; i < int(N); i++)
#define all(x) begin(x), end(x)

using namespace std;

using ll = long long;

const int MAXN = 500;
const int MAXA = 500;
stack<bitset<2*MAXN*MAXA>> st;
bitset<2*MAXN*MAXA> nt[MAXN];
bitset<2*MAXN*MAXA> tot;
bitset<2*MAXN*MAXA> pos;
vector<int> arr;
int S = 0;
void recur(int tl, int tr) {
    if (tl == tr) {
        nt[tl] = (st.top()>>(S-arr[tr]));
        if (tr == arr.size()-1) {
            tot = st.top()|(st.top() << (2*arr[tr]));
            tot >>= S;
        }
    }
    else {
        int tm = (tl + tr)/2;
        st.push(st.top());
        for (int i = tl; i <= tm; i++) {
            st.top() |= (st.top() << (2*arr[i]));
        }
        recur(tm+1, tr);
        st.pop();
        st.push(st.top());
        for (int i = tm+1; i <= tr; i++) {
            st.top() |= (st.top() << (2*arr[i]));
        }
        recur(tl, tm);
        st.pop();
    }

}
int main() {
	cin.tie(0);
	cin.sync_with_stdio(0);
	int N;
	cin >> N;
	st.emplace();
	st.top()[0] = 1;
	pos.set();
	FR(i, N) {
        int a;
        cin >> a;
        S += a;
        arr.push_back(a);
    }
    recur(0, N-1);
    if (!tot[0]) {
        cout << "0" << '\n';
        return 0;
    }
    else {
        FR(i, N) {
            pos &= (nt[i]);
        }
        vector<int> res;
        for (int i = 1; i < 2*MAXN*MAXA; i++) {
            if (pos[i]) {
                res.push_back(i);
            }
        }
        cout << res.size() << '\n';
        for (int r : res) {
            cout << r << " ";
        }
    }
	return 0;
}

Compilation message

bootfall.cpp: In function 'void recur(int, int)':
bootfall.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         if (tr == arr.size()-1) {
      |             ~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1512 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 4 ms 2156 KB Output is correct
6 Correct 4 ms 1640 KB Output is correct
7 Correct 3 ms 1512 KB Output is correct
8 Correct 4 ms 2156 KB Output is correct
9 Correct 4 ms 2028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1512 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 4 ms 2156 KB Output is correct
6 Correct 4 ms 1640 KB Output is correct
7 Correct 3 ms 1512 KB Output is correct
8 Correct 4 ms 2156 KB Output is correct
9 Correct 4 ms 2028 KB Output is correct
10 Correct 7 ms 3436 KB Output is correct
11 Correct 7 ms 3436 KB Output is correct
12 Correct 7 ms 3436 KB Output is correct
13 Correct 7 ms 3180 KB Output is correct
14 Correct 8 ms 3456 KB Output is correct
15 Correct 7 ms 3308 KB Output is correct
16 Correct 7 ms 3436 KB Output is correct
17 Correct 5 ms 2668 KB Output is correct
18 Correct 6 ms 3052 KB Output is correct
19 Correct 6 ms 3180 KB Output is correct
20 Correct 7 ms 3564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1512 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 4 ms 2156 KB Output is correct
6 Correct 4 ms 1640 KB Output is correct
7 Correct 3 ms 1512 KB Output is correct
8 Correct 4 ms 2156 KB Output is correct
9 Correct 4 ms 2028 KB Output is correct
10 Correct 7 ms 3436 KB Output is correct
11 Correct 7 ms 3436 KB Output is correct
12 Correct 7 ms 3436 KB Output is correct
13 Correct 7 ms 3180 KB Output is correct
14 Correct 8 ms 3456 KB Output is correct
15 Correct 7 ms 3308 KB Output is correct
16 Correct 7 ms 3436 KB Output is correct
17 Correct 5 ms 2668 KB Output is correct
18 Correct 6 ms 3052 KB Output is correct
19 Correct 6 ms 3180 KB Output is correct
20 Correct 7 ms 3564 KB Output is correct
21 Correct 14 ms 5680 KB Output is correct
22 Correct 16 ms 6492 KB Output is correct
23 Correct 11 ms 4784 KB Output is correct
24 Correct 21 ms 7660 KB Output is correct
25 Correct 23 ms 7660 KB Output is correct
26 Correct 22 ms 8036 KB Output is correct
27 Correct 22 ms 8036 KB Output is correct
28 Correct 22 ms 8036 KB Output is correct
29 Correct 22 ms 8036 KB Output is correct
30 Correct 23 ms 8164 KB Output is correct
31 Correct 22 ms 8036 KB Output is correct
32 Correct 22 ms 8036 KB Output is correct
33 Correct 21 ms 8036 KB Output is correct
34 Correct 21 ms 8036 KB Output is correct
35 Correct 21 ms 8036 KB Output is correct
36 Correct 22 ms 8036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1512 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 4 ms 2156 KB Output is correct
6 Correct 4 ms 1640 KB Output is correct
7 Correct 3 ms 1512 KB Output is correct
8 Correct 4 ms 2156 KB Output is correct
9 Correct 4 ms 2028 KB Output is correct
10 Correct 7 ms 3436 KB Output is correct
11 Correct 7 ms 3436 KB Output is correct
12 Correct 7 ms 3436 KB Output is correct
13 Correct 7 ms 3180 KB Output is correct
14 Correct 8 ms 3456 KB Output is correct
15 Correct 7 ms 3308 KB Output is correct
16 Correct 7 ms 3436 KB Output is correct
17 Correct 5 ms 2668 KB Output is correct
18 Correct 6 ms 3052 KB Output is correct
19 Correct 6 ms 3180 KB Output is correct
20 Correct 7 ms 3564 KB Output is correct
21 Correct 14 ms 5680 KB Output is correct
22 Correct 16 ms 6492 KB Output is correct
23 Correct 11 ms 4784 KB Output is correct
24 Correct 21 ms 7660 KB Output is correct
25 Correct 23 ms 7660 KB Output is correct
26 Correct 22 ms 8036 KB Output is correct
27 Correct 22 ms 8036 KB Output is correct
28 Correct 22 ms 8036 KB Output is correct
29 Correct 22 ms 8036 KB Output is correct
30 Correct 23 ms 8164 KB Output is correct
31 Correct 22 ms 8036 KB Output is correct
32 Correct 22 ms 8036 KB Output is correct
33 Correct 21 ms 8036 KB Output is correct
34 Correct 21 ms 8036 KB Output is correct
35 Correct 21 ms 8036 KB Output is correct
36 Correct 22 ms 8036 KB Output is correct
37 Correct 45 ms 14372 KB Output is correct
38 Correct 45 ms 14372 KB Output is correct
39 Correct 55 ms 17316 KB Output is correct
40 Correct 62 ms 18852 KB Output is correct
41 Correct 60 ms 18852 KB Output is correct
42 Correct 57 ms 17444 KB Output is correct
43 Correct 56 ms 17196 KB Output is correct
44 Correct 59 ms 17324 KB Output is correct
45 Correct 57 ms 17452 KB Output is correct
46 Correct 60 ms 18852 KB Output is correct
47 Correct 59 ms 17452 KB Output is correct
48 Correct 59 ms 17452 KB Output is correct
49 Correct 56 ms 17444 KB Output is correct
50 Correct 57 ms 17444 KB Output is correct
51 Correct 52 ms 17444 KB Output is correct
52 Correct 63 ms 18852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1512 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 4 ms 2156 KB Output is correct
6 Correct 4 ms 1640 KB Output is correct
7 Correct 3 ms 1512 KB Output is correct
8 Correct 4 ms 2156 KB Output is correct
9 Correct 4 ms 2028 KB Output is correct
10 Correct 7 ms 3436 KB Output is correct
11 Correct 7 ms 3436 KB Output is correct
12 Correct 7 ms 3436 KB Output is correct
13 Correct 7 ms 3180 KB Output is correct
14 Correct 8 ms 3456 KB Output is correct
15 Correct 7 ms 3308 KB Output is correct
16 Correct 7 ms 3436 KB Output is correct
17 Correct 5 ms 2668 KB Output is correct
18 Correct 6 ms 3052 KB Output is correct
19 Correct 6 ms 3180 KB Output is correct
20 Correct 7 ms 3564 KB Output is correct
21 Correct 14 ms 5680 KB Output is correct
22 Correct 16 ms 6492 KB Output is correct
23 Correct 11 ms 4784 KB Output is correct
24 Correct 21 ms 7660 KB Output is correct
25 Correct 23 ms 7660 KB Output is correct
26 Correct 22 ms 8036 KB Output is correct
27 Correct 22 ms 8036 KB Output is correct
28 Correct 22 ms 8036 KB Output is correct
29 Correct 22 ms 8036 KB Output is correct
30 Correct 23 ms 8164 KB Output is correct
31 Correct 22 ms 8036 KB Output is correct
32 Correct 22 ms 8036 KB Output is correct
33 Correct 21 ms 8036 KB Output is correct
34 Correct 21 ms 8036 KB Output is correct
35 Correct 21 ms 8036 KB Output is correct
36 Correct 22 ms 8036 KB Output is correct
37 Correct 45 ms 14372 KB Output is correct
38 Correct 45 ms 14372 KB Output is correct
39 Correct 55 ms 17316 KB Output is correct
40 Correct 62 ms 18852 KB Output is correct
41 Correct 60 ms 18852 KB Output is correct
42 Correct 57 ms 17444 KB Output is correct
43 Correct 56 ms 17196 KB Output is correct
44 Correct 59 ms 17324 KB Output is correct
45 Correct 57 ms 17452 KB Output is correct
46 Correct 60 ms 18852 KB Output is correct
47 Correct 59 ms 17452 KB Output is correct
48 Correct 59 ms 17452 KB Output is correct
49 Correct 56 ms 17444 KB Output is correct
50 Correct 57 ms 17444 KB Output is correct
51 Correct 52 ms 17444 KB Output is correct
52 Correct 63 ms 18852 KB Output is correct
53 Correct 70 ms 20612 KB Output is correct
54 Correct 83 ms 23724 KB Output is correct
55 Correct 86 ms 24180 KB Output is correct
56 Correct 72 ms 21044 KB Output is correct
57 Correct 85 ms 24052 KB Output is correct
58 Correct 83 ms 23724 KB Output is correct
59 Correct 86 ms 24052 KB Output is correct
60 Correct 79 ms 23724 KB Output is correct
61 Correct 87 ms 23924 KB Output is correct
62 Correct 78 ms 22124 KB Output is correct
63 Correct 78 ms 22252 KB Output is correct
64 Correct 78 ms 21820 KB Output is correct
65 Correct 74 ms 21636 KB Output is correct
66 Correct 74 ms 21204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1512 KB Output is correct
3 Correct 1 ms 1260 KB Output is correct
4 Correct 3 ms 1260 KB Output is correct
5 Correct 4 ms 2156 KB Output is correct
6 Correct 4 ms 1640 KB Output is correct
7 Correct 3 ms 1512 KB Output is correct
8 Correct 4 ms 2156 KB Output is correct
9 Correct 4 ms 2028 KB Output is correct
10 Correct 7 ms 3436 KB Output is correct
11 Correct 7 ms 3436 KB Output is correct
12 Correct 7 ms 3436 KB Output is correct
13 Correct 7 ms 3180 KB Output is correct
14 Correct 8 ms 3456 KB Output is correct
15 Correct 7 ms 3308 KB Output is correct
16 Correct 7 ms 3436 KB Output is correct
17 Correct 5 ms 2668 KB Output is correct
18 Correct 6 ms 3052 KB Output is correct
19 Correct 6 ms 3180 KB Output is correct
20 Correct 7 ms 3564 KB Output is correct
21 Correct 14 ms 5680 KB Output is correct
22 Correct 16 ms 6492 KB Output is correct
23 Correct 11 ms 4784 KB Output is correct
24 Correct 21 ms 7660 KB Output is correct
25 Correct 23 ms 7660 KB Output is correct
26 Correct 22 ms 8036 KB Output is correct
27 Correct 22 ms 8036 KB Output is correct
28 Correct 22 ms 8036 KB Output is correct
29 Correct 22 ms 8036 KB Output is correct
30 Correct 23 ms 8164 KB Output is correct
31 Correct 22 ms 8036 KB Output is correct
32 Correct 22 ms 8036 KB Output is correct
33 Correct 21 ms 8036 KB Output is correct
34 Correct 21 ms 8036 KB Output is correct
35 Correct 21 ms 8036 KB Output is correct
36 Correct 22 ms 8036 KB Output is correct
37 Correct 45 ms 14372 KB Output is correct
38 Correct 45 ms 14372 KB Output is correct
39 Correct 55 ms 17316 KB Output is correct
40 Correct 62 ms 18852 KB Output is correct
41 Correct 60 ms 18852 KB Output is correct
42 Correct 57 ms 17444 KB Output is correct
43 Correct 56 ms 17196 KB Output is correct
44 Correct 59 ms 17324 KB Output is correct
45 Correct 57 ms 17452 KB Output is correct
46 Correct 60 ms 18852 KB Output is correct
47 Correct 59 ms 17452 KB Output is correct
48 Correct 59 ms 17452 KB Output is correct
49 Correct 56 ms 17444 KB Output is correct
50 Correct 57 ms 17444 KB Output is correct
51 Correct 52 ms 17444 KB Output is correct
52 Correct 63 ms 18852 KB Output is correct
53 Correct 70 ms 20612 KB Output is correct
54 Correct 83 ms 23724 KB Output is correct
55 Correct 86 ms 24180 KB Output is correct
56 Correct 72 ms 21044 KB Output is correct
57 Correct 85 ms 24052 KB Output is correct
58 Correct 83 ms 23724 KB Output is correct
59 Correct 86 ms 24052 KB Output is correct
60 Correct 79 ms 23724 KB Output is correct
61 Correct 87 ms 23924 KB Output is correct
62 Correct 78 ms 22124 KB Output is correct
63 Correct 78 ms 22252 KB Output is correct
64 Correct 78 ms 21820 KB Output is correct
65 Correct 74 ms 21636 KB Output is correct
66 Correct 74 ms 21204 KB Output is correct
67 Correct 97 ms 26988 KB Output is correct
68 Correct 114 ms 32952 KB Output is correct
69 Correct 128 ms 33768 KB Output is correct
70 Correct 122 ms 33408 KB Output is correct
71 Correct 123 ms 33516 KB Output is correct
72 Correct 116 ms 32932 KB Output is correct
73 Correct 115 ms 32804 KB Output is correct
74 Correct 126 ms 33800 KB Output is correct
75 Correct 125 ms 33640 KB Output is correct
76 Correct 128 ms 33768 KB Output is correct
77 Correct 128 ms 33896 KB Output is correct