Submission #137118

# Submission time Handle Problem Language Result Execution time Memory
137118 2019-07-27T05:37:41 Z meatrow Bootfall (IZhO17_bootfall) C++17
100 / 100
855 ms 2712 KB
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

const int N = 125001;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    bitset<N> dp;
    int n;
    cin >> n;
    vector<int> a(n);
    int total = 0;
    dp.set(0);
    for (int& i : a) {
        cin >> i;
        total += i;
        dp |= dp << i;
    }
    if (total % 2 || !dp[total / 2]) {
        cout << 0;
        return 0;
    }
    vector<int> cnt(N * 2);
    bitset<N> kek;
    kek.set(0);
    for (int i = 0; i < n; i++) {
        dp = kek;
        for (int j = i + 1; j < n; j++) {
            dp |= dp << a[j];
        }
        kek |= kek << a[i];
        for (int j = 0; j * 2 < total - a[i]; j++) {
            cnt[abs(total - a[i] - 2 * j)] += dp[j];
        }
    }
    vector<int> ans;
    for (int i = 1; i < N * 2; i++) {
        if (cnt[i] == n) {
            ans.push_back(i);
        }
    }
    cout << ans.size() << '\n';
    for (int& i : ans) {
        cout << i << ' ';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1400 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 1400 KB Output is correct
5 Correct 4 ms 1400 KB Output is correct
6 Correct 4 ms 1400 KB Output is correct
7 Correct 3 ms 1400 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 3 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1400 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 1400 KB Output is correct
5 Correct 4 ms 1400 KB Output is correct
6 Correct 4 ms 1400 KB Output is correct
7 Correct 3 ms 1400 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 3 ms 1400 KB Output is correct
10 Correct 6 ms 1400 KB Output is correct
11 Correct 6 ms 1400 KB Output is correct
12 Correct 6 ms 1400 KB Output is correct
13 Correct 5 ms 1400 KB Output is correct
14 Correct 6 ms 1528 KB Output is correct
15 Correct 12 ms 1404 KB Output is correct
16 Correct 18 ms 1400 KB Output is correct
17 Correct 5 ms 1400 KB Output is correct
18 Correct 5 ms 1400 KB Output is correct
19 Correct 5 ms 1400 KB Output is correct
20 Correct 5 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1400 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 1400 KB Output is correct
5 Correct 4 ms 1400 KB Output is correct
6 Correct 4 ms 1400 KB Output is correct
7 Correct 3 ms 1400 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 3 ms 1400 KB Output is correct
10 Correct 6 ms 1400 KB Output is correct
11 Correct 6 ms 1400 KB Output is correct
12 Correct 6 ms 1400 KB Output is correct
13 Correct 5 ms 1400 KB Output is correct
14 Correct 6 ms 1528 KB Output is correct
15 Correct 12 ms 1404 KB Output is correct
16 Correct 18 ms 1400 KB Output is correct
17 Correct 5 ms 1400 KB Output is correct
18 Correct 5 ms 1400 KB Output is correct
19 Correct 5 ms 1400 KB Output is correct
20 Correct 5 ms 1400 KB Output is correct
21 Correct 14 ms 1472 KB Output is correct
22 Correct 17 ms 1400 KB Output is correct
23 Correct 10 ms 1400 KB Output is correct
24 Correct 25 ms 1400 KB Output is correct
25 Correct 27 ms 1400 KB Output is correct
26 Correct 29 ms 1400 KB Output is correct
27 Correct 29 ms 1400 KB Output is correct
28 Correct 29 ms 1436 KB Output is correct
29 Correct 29 ms 1400 KB Output is correct
30 Correct 27 ms 1400 KB Output is correct
31 Correct 29 ms 1400 KB Output is correct
32 Correct 28 ms 1400 KB Output is correct
33 Correct 29 ms 1400 KB Output is correct
34 Correct 29 ms 1400 KB Output is correct
35 Correct 29 ms 1468 KB Output is correct
36 Correct 28 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1400 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 1400 KB Output is correct
5 Correct 4 ms 1400 KB Output is correct
6 Correct 4 ms 1400 KB Output is correct
7 Correct 3 ms 1400 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 3 ms 1400 KB Output is correct
10 Correct 6 ms 1400 KB Output is correct
11 Correct 6 ms 1400 KB Output is correct
12 Correct 6 ms 1400 KB Output is correct
13 Correct 5 ms 1400 KB Output is correct
14 Correct 6 ms 1528 KB Output is correct
15 Correct 12 ms 1404 KB Output is correct
16 Correct 18 ms 1400 KB Output is correct
17 Correct 5 ms 1400 KB Output is correct
18 Correct 5 ms 1400 KB Output is correct
19 Correct 5 ms 1400 KB Output is correct
20 Correct 5 ms 1400 KB Output is correct
21 Correct 14 ms 1472 KB Output is correct
22 Correct 17 ms 1400 KB Output is correct
23 Correct 10 ms 1400 KB Output is correct
24 Correct 25 ms 1400 KB Output is correct
25 Correct 27 ms 1400 KB Output is correct
26 Correct 29 ms 1400 KB Output is correct
27 Correct 29 ms 1400 KB Output is correct
28 Correct 29 ms 1436 KB Output is correct
29 Correct 29 ms 1400 KB Output is correct
30 Correct 27 ms 1400 KB Output is correct
31 Correct 29 ms 1400 KB Output is correct
32 Correct 28 ms 1400 KB Output is correct
33 Correct 29 ms 1400 KB Output is correct
34 Correct 29 ms 1400 KB Output is correct
35 Correct 29 ms 1468 KB Output is correct
36 Correct 28 ms 1528 KB Output is correct
37 Correct 105 ms 1596 KB Output is correct
38 Correct 105 ms 1656 KB Output is correct
39 Correct 178 ms 1500 KB Output is correct
40 Correct 190 ms 1564 KB Output is correct
41 Correct 213 ms 1400 KB Output is correct
42 Correct 165 ms 1600 KB Output is correct
43 Correct 173 ms 1724 KB Output is correct
44 Correct 176 ms 1912 KB Output is correct
45 Correct 180 ms 1720 KB Output is correct
46 Correct 185 ms 1400 KB Output is correct
47 Correct 165 ms 1552 KB Output is correct
48 Correct 182 ms 1712 KB Output is correct
49 Correct 187 ms 1528 KB Output is correct
50 Correct 171 ms 1592 KB Output is correct
51 Correct 3 ms 376 KB Output is correct
52 Correct 214 ms 1912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1400 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 1400 KB Output is correct
5 Correct 4 ms 1400 KB Output is correct
6 Correct 4 ms 1400 KB Output is correct
7 Correct 3 ms 1400 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 3 ms 1400 KB Output is correct
10 Correct 6 ms 1400 KB Output is correct
11 Correct 6 ms 1400 KB Output is correct
12 Correct 6 ms 1400 KB Output is correct
13 Correct 5 ms 1400 KB Output is correct
14 Correct 6 ms 1528 KB Output is correct
15 Correct 12 ms 1404 KB Output is correct
16 Correct 18 ms 1400 KB Output is correct
17 Correct 5 ms 1400 KB Output is correct
18 Correct 5 ms 1400 KB Output is correct
19 Correct 5 ms 1400 KB Output is correct
20 Correct 5 ms 1400 KB Output is correct
21 Correct 14 ms 1472 KB Output is correct
22 Correct 17 ms 1400 KB Output is correct
23 Correct 10 ms 1400 KB Output is correct
24 Correct 25 ms 1400 KB Output is correct
25 Correct 27 ms 1400 KB Output is correct
26 Correct 29 ms 1400 KB Output is correct
27 Correct 29 ms 1400 KB Output is correct
28 Correct 29 ms 1436 KB Output is correct
29 Correct 29 ms 1400 KB Output is correct
30 Correct 27 ms 1400 KB Output is correct
31 Correct 29 ms 1400 KB Output is correct
32 Correct 28 ms 1400 KB Output is correct
33 Correct 29 ms 1400 KB Output is correct
34 Correct 29 ms 1400 KB Output is correct
35 Correct 29 ms 1468 KB Output is correct
36 Correct 28 ms 1528 KB Output is correct
37 Correct 105 ms 1596 KB Output is correct
38 Correct 105 ms 1656 KB Output is correct
39 Correct 178 ms 1500 KB Output is correct
40 Correct 190 ms 1564 KB Output is correct
41 Correct 213 ms 1400 KB Output is correct
42 Correct 165 ms 1600 KB Output is correct
43 Correct 173 ms 1724 KB Output is correct
44 Correct 176 ms 1912 KB Output is correct
45 Correct 180 ms 1720 KB Output is correct
46 Correct 185 ms 1400 KB Output is correct
47 Correct 165 ms 1552 KB Output is correct
48 Correct 182 ms 1712 KB Output is correct
49 Correct 187 ms 1528 KB Output is correct
50 Correct 171 ms 1592 KB Output is correct
51 Correct 3 ms 376 KB Output is correct
52 Correct 214 ms 1912 KB Output is correct
53 Correct 239 ms 1688 KB Output is correct
54 Correct 333 ms 1784 KB Output is correct
55 Correct 373 ms 2040 KB Output is correct
56 Correct 268 ms 1784 KB Output is correct
57 Correct 384 ms 2064 KB Output is correct
58 Correct 342 ms 1784 KB Output is correct
59 Correct 344 ms 1912 KB Output is correct
60 Correct 3 ms 376 KB Output is correct
61 Correct 351 ms 1912 KB Output is correct
62 Correct 309 ms 1944 KB Output is correct
63 Correct 315 ms 1944 KB Output is correct
64 Correct 307 ms 1912 KB Output is correct
65 Correct 263 ms 1400 KB Output is correct
66 Correct 260 ms 1500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1400 KB Output is correct
2 Correct 3 ms 1400 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 1400 KB Output is correct
5 Correct 4 ms 1400 KB Output is correct
6 Correct 4 ms 1400 KB Output is correct
7 Correct 3 ms 1400 KB Output is correct
8 Correct 3 ms 1400 KB Output is correct
9 Correct 3 ms 1400 KB Output is correct
10 Correct 6 ms 1400 KB Output is correct
11 Correct 6 ms 1400 KB Output is correct
12 Correct 6 ms 1400 KB Output is correct
13 Correct 5 ms 1400 KB Output is correct
14 Correct 6 ms 1528 KB Output is correct
15 Correct 12 ms 1404 KB Output is correct
16 Correct 18 ms 1400 KB Output is correct
17 Correct 5 ms 1400 KB Output is correct
18 Correct 5 ms 1400 KB Output is correct
19 Correct 5 ms 1400 KB Output is correct
20 Correct 5 ms 1400 KB Output is correct
21 Correct 14 ms 1472 KB Output is correct
22 Correct 17 ms 1400 KB Output is correct
23 Correct 10 ms 1400 KB Output is correct
24 Correct 25 ms 1400 KB Output is correct
25 Correct 27 ms 1400 KB Output is correct
26 Correct 29 ms 1400 KB Output is correct
27 Correct 29 ms 1400 KB Output is correct
28 Correct 29 ms 1436 KB Output is correct
29 Correct 29 ms 1400 KB Output is correct
30 Correct 27 ms 1400 KB Output is correct
31 Correct 29 ms 1400 KB Output is correct
32 Correct 28 ms 1400 KB Output is correct
33 Correct 29 ms 1400 KB Output is correct
34 Correct 29 ms 1400 KB Output is correct
35 Correct 29 ms 1468 KB Output is correct
36 Correct 28 ms 1528 KB Output is correct
37 Correct 105 ms 1596 KB Output is correct
38 Correct 105 ms 1656 KB Output is correct
39 Correct 178 ms 1500 KB Output is correct
40 Correct 190 ms 1564 KB Output is correct
41 Correct 213 ms 1400 KB Output is correct
42 Correct 165 ms 1600 KB Output is correct
43 Correct 173 ms 1724 KB Output is correct
44 Correct 176 ms 1912 KB Output is correct
45 Correct 180 ms 1720 KB Output is correct
46 Correct 185 ms 1400 KB Output is correct
47 Correct 165 ms 1552 KB Output is correct
48 Correct 182 ms 1712 KB Output is correct
49 Correct 187 ms 1528 KB Output is correct
50 Correct 171 ms 1592 KB Output is correct
51 Correct 3 ms 376 KB Output is correct
52 Correct 214 ms 1912 KB Output is correct
53 Correct 239 ms 1688 KB Output is correct
54 Correct 333 ms 1784 KB Output is correct
55 Correct 373 ms 2040 KB Output is correct
56 Correct 268 ms 1784 KB Output is correct
57 Correct 384 ms 2064 KB Output is correct
58 Correct 342 ms 1784 KB Output is correct
59 Correct 344 ms 1912 KB Output is correct
60 Correct 3 ms 376 KB Output is correct
61 Correct 351 ms 1912 KB Output is correct
62 Correct 309 ms 1944 KB Output is correct
63 Correct 315 ms 1944 KB Output is correct
64 Correct 307 ms 1912 KB Output is correct
65 Correct 263 ms 1400 KB Output is correct
66 Correct 260 ms 1500 KB Output is correct
67 Correct 442 ms 1888 KB Output is correct
68 Correct 5 ms 400 KB Output is correct
69 Correct 816 ms 2608 KB Output is correct
70 Correct 717 ms 2212 KB Output is correct
71 Correct 712 ms 2076 KB Output is correct
72 Correct 708 ms 1400 KB Output is correct
73 Correct 705 ms 1400 KB Output is correct
74 Correct 830 ms 2584 KB Output is correct
75 Correct 767 ms 2328 KB Output is correct
76 Correct 855 ms 2584 KB Output is correct
77 Correct 845 ms 2712 KB Output is correct