Submission #566392

# Submission time Handle Problem Language Result Execution time Memory
566392 2022-05-22T09:42:09 Z shrimb Bootfall (IZhO17_bootfall) C++17
100 / 100
474 ms 2024 KB
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx,avx2,fma")

#include"bits/stdc++.h"
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;

// #define int long long
#define endl '\n'
#define mod 1000000007
//\
#define mod 1686876991

const int maxn = 501;
const int maxs = maxn * maxn;

int dp[maxn * maxn];
bitset<maxn*maxn> ans;
int n, tot, ex=-1, total;
int a[maxn];

void add (int x) {
    for (int i = maxs ; i >= x ; i--) {
        dp[i] += dp[i - x];
        dp[i] %= mod;
    }
}

void rem (int x) {
    for (int i = x ; i <= maxs ; i++) {
        dp[i] =  (mod + dp[i] - dp[i-x]) % mod;
    }
}

signed main () {
    cin.tie(0)->sync_with_stdio(0);
    dp[0] = 1;
    cin >> n;
    for (int i = 0 ; i < n ; i++) cin >> a[i], total += a[i], add(a[i]);
    for (int i = 0 ; i <= total ; i++) ans[i] = 1;
    if (!dp[total/2]) {
        cout << 0 << endl;
        return 0;
    }
    // cerr << "here\n";
    ans[0] = 0;
    for (int i = 0 ; i < n ; i++) {
        tot = total - a[i];
        rem(a[i]);
        ex = i;
        for (int j = 1 ; j <= total ; j++) {
            if ((tot+j)&1||!dp[(tot+j)/2]) {
                ans[j] = 0;
            }
        }
        add(a[i]);
    }
    cout << ans.count() << endl;
    for (int i = 0 ; i <= total ; i++) if (ans[i]) cout << i << " ";
}

Compilation message

bootfall.cpp:17:1: warning: multi-line comment [-Wcomment]
   17 | //\
      | ^
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Correct 6 ms 1236 KB Output is correct
3 Correct 2 ms 1236 KB Output is correct
4 Correct 3 ms 1236 KB Output is correct
5 Correct 9 ms 1304 KB Output is correct
6 Correct 7 ms 1304 KB Output is correct
7 Correct 4 ms 1236 KB Output is correct
8 Correct 8 ms 1236 KB Output is correct
9 Correct 7 ms 1304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Correct 6 ms 1236 KB Output is correct
3 Correct 2 ms 1236 KB Output is correct
4 Correct 3 ms 1236 KB Output is correct
5 Correct 9 ms 1304 KB Output is correct
6 Correct 7 ms 1304 KB Output is correct
7 Correct 4 ms 1236 KB Output is correct
8 Correct 8 ms 1236 KB Output is correct
9 Correct 7 ms 1304 KB Output is correct
10 Correct 22 ms 1236 KB Output is correct
11 Correct 32 ms 1236 KB Output is correct
12 Correct 24 ms 1304 KB Output is correct
13 Correct 25 ms 1304 KB Output is correct
14 Correct 25 ms 1300 KB Output is correct
15 Correct 30 ms 1304 KB Output is correct
16 Correct 31 ms 1236 KB Output is correct
17 Correct 17 ms 1300 KB Output is correct
18 Correct 23 ms 1300 KB Output is correct
19 Correct 26 ms 1304 KB Output is correct
20 Correct 19 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Correct 6 ms 1236 KB Output is correct
3 Correct 2 ms 1236 KB Output is correct
4 Correct 3 ms 1236 KB Output is correct
5 Correct 9 ms 1304 KB Output is correct
6 Correct 7 ms 1304 KB Output is correct
7 Correct 4 ms 1236 KB Output is correct
8 Correct 8 ms 1236 KB Output is correct
9 Correct 7 ms 1304 KB Output is correct
10 Correct 22 ms 1236 KB Output is correct
11 Correct 32 ms 1236 KB Output is correct
12 Correct 24 ms 1304 KB Output is correct
13 Correct 25 ms 1304 KB Output is correct
14 Correct 25 ms 1300 KB Output is correct
15 Correct 30 ms 1304 KB Output is correct
16 Correct 31 ms 1236 KB Output is correct
17 Correct 17 ms 1300 KB Output is correct
18 Correct 23 ms 1300 KB Output is correct
19 Correct 26 ms 1304 KB Output is correct
20 Correct 19 ms 1236 KB Output is correct
21 Correct 43 ms 1284 KB Output is correct
22 Correct 52 ms 1236 KB Output is correct
23 Correct 36 ms 1284 KB Output is correct
24 Correct 70 ms 1284 KB Output is correct
25 Correct 59 ms 1236 KB Output is correct
26 Correct 61 ms 1300 KB Output is correct
27 Correct 63 ms 1300 KB Output is correct
28 Correct 64 ms 1288 KB Output is correct
29 Correct 61 ms 1304 KB Output is correct
30 Correct 64 ms 1308 KB Output is correct
31 Correct 62 ms 1296 KB Output is correct
32 Correct 66 ms 1284 KB Output is correct
33 Correct 63 ms 1292 KB Output is correct
34 Correct 61 ms 1292 KB Output is correct
35 Correct 62 ms 1356 KB Output is correct
36 Correct 70 ms 1296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Correct 6 ms 1236 KB Output is correct
3 Correct 2 ms 1236 KB Output is correct
4 Correct 3 ms 1236 KB Output is correct
5 Correct 9 ms 1304 KB Output is correct
6 Correct 7 ms 1304 KB Output is correct
7 Correct 4 ms 1236 KB Output is correct
8 Correct 8 ms 1236 KB Output is correct
9 Correct 7 ms 1304 KB Output is correct
10 Correct 22 ms 1236 KB Output is correct
11 Correct 32 ms 1236 KB Output is correct
12 Correct 24 ms 1304 KB Output is correct
13 Correct 25 ms 1304 KB Output is correct
14 Correct 25 ms 1300 KB Output is correct
15 Correct 30 ms 1304 KB Output is correct
16 Correct 31 ms 1236 KB Output is correct
17 Correct 17 ms 1300 KB Output is correct
18 Correct 23 ms 1300 KB Output is correct
19 Correct 26 ms 1304 KB Output is correct
20 Correct 19 ms 1236 KB Output is correct
21 Correct 43 ms 1284 KB Output is correct
22 Correct 52 ms 1236 KB Output is correct
23 Correct 36 ms 1284 KB Output is correct
24 Correct 70 ms 1284 KB Output is correct
25 Correct 59 ms 1236 KB Output is correct
26 Correct 61 ms 1300 KB Output is correct
27 Correct 63 ms 1300 KB Output is correct
28 Correct 64 ms 1288 KB Output is correct
29 Correct 61 ms 1304 KB Output is correct
30 Correct 64 ms 1308 KB Output is correct
31 Correct 62 ms 1296 KB Output is correct
32 Correct 66 ms 1284 KB Output is correct
33 Correct 63 ms 1292 KB Output is correct
34 Correct 61 ms 1292 KB Output is correct
35 Correct 62 ms 1356 KB Output is correct
36 Correct 70 ms 1296 KB Output is correct
37 Correct 129 ms 1284 KB Output is correct
38 Correct 122 ms 1288 KB Output is correct
39 Correct 181 ms 1284 KB Output is correct
40 Correct 187 ms 1412 KB Output is correct
41 Correct 202 ms 1288 KB Output is correct
42 Correct 168 ms 1292 KB Output is correct
43 Correct 163 ms 1424 KB Output is correct
44 Correct 171 ms 1416 KB Output is correct
45 Correct 168 ms 1424 KB Output is correct
46 Correct 175 ms 1288 KB Output is correct
47 Correct 172 ms 1292 KB Output is correct
48 Correct 165 ms 1292 KB Output is correct
49 Correct 174 ms 1288 KB Output is correct
50 Correct 163 ms 1292 KB Output is correct
51 Correct 167 ms 1356 KB Output is correct
52 Correct 187 ms 1412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Correct 6 ms 1236 KB Output is correct
3 Correct 2 ms 1236 KB Output is correct
4 Correct 3 ms 1236 KB Output is correct
5 Correct 9 ms 1304 KB Output is correct
6 Correct 7 ms 1304 KB Output is correct
7 Correct 4 ms 1236 KB Output is correct
8 Correct 8 ms 1236 KB Output is correct
9 Correct 7 ms 1304 KB Output is correct
10 Correct 22 ms 1236 KB Output is correct
11 Correct 32 ms 1236 KB Output is correct
12 Correct 24 ms 1304 KB Output is correct
13 Correct 25 ms 1304 KB Output is correct
14 Correct 25 ms 1300 KB Output is correct
15 Correct 30 ms 1304 KB Output is correct
16 Correct 31 ms 1236 KB Output is correct
17 Correct 17 ms 1300 KB Output is correct
18 Correct 23 ms 1300 KB Output is correct
19 Correct 26 ms 1304 KB Output is correct
20 Correct 19 ms 1236 KB Output is correct
21 Correct 43 ms 1284 KB Output is correct
22 Correct 52 ms 1236 KB Output is correct
23 Correct 36 ms 1284 KB Output is correct
24 Correct 70 ms 1284 KB Output is correct
25 Correct 59 ms 1236 KB Output is correct
26 Correct 61 ms 1300 KB Output is correct
27 Correct 63 ms 1300 KB Output is correct
28 Correct 64 ms 1288 KB Output is correct
29 Correct 61 ms 1304 KB Output is correct
30 Correct 64 ms 1308 KB Output is correct
31 Correct 62 ms 1296 KB Output is correct
32 Correct 66 ms 1284 KB Output is correct
33 Correct 63 ms 1292 KB Output is correct
34 Correct 61 ms 1292 KB Output is correct
35 Correct 62 ms 1356 KB Output is correct
36 Correct 70 ms 1296 KB Output is correct
37 Correct 129 ms 1284 KB Output is correct
38 Correct 122 ms 1288 KB Output is correct
39 Correct 181 ms 1284 KB Output is correct
40 Correct 187 ms 1412 KB Output is correct
41 Correct 202 ms 1288 KB Output is correct
42 Correct 168 ms 1292 KB Output is correct
43 Correct 163 ms 1424 KB Output is correct
44 Correct 171 ms 1416 KB Output is correct
45 Correct 168 ms 1424 KB Output is correct
46 Correct 175 ms 1288 KB Output is correct
47 Correct 172 ms 1292 KB Output is correct
48 Correct 165 ms 1292 KB Output is correct
49 Correct 174 ms 1288 KB Output is correct
50 Correct 163 ms 1292 KB Output is correct
51 Correct 167 ms 1356 KB Output is correct
52 Correct 187 ms 1412 KB Output is correct
53 Correct 192 ms 1424 KB Output is correct
54 Correct 241 ms 1420 KB Output is correct
55 Correct 259 ms 1552 KB Output is correct
56 Correct 220 ms 1424 KB Output is correct
57 Correct 258 ms 1740 KB Output is correct
58 Correct 255 ms 1544 KB Output is correct
59 Correct 240 ms 1428 KB Output is correct
60 Correct 240 ms 1412 KB Output is correct
61 Correct 243 ms 1428 KB Output is correct
62 Correct 242 ms 1560 KB Output is correct
63 Correct 234 ms 1564 KB Output is correct
64 Correct 230 ms 1668 KB Output is correct
65 Correct 222 ms 1484 KB Output is correct
66 Correct 221 ms 1416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1236 KB Output is correct
2 Correct 6 ms 1236 KB Output is correct
3 Correct 2 ms 1236 KB Output is correct
4 Correct 3 ms 1236 KB Output is correct
5 Correct 9 ms 1304 KB Output is correct
6 Correct 7 ms 1304 KB Output is correct
7 Correct 4 ms 1236 KB Output is correct
8 Correct 8 ms 1236 KB Output is correct
9 Correct 7 ms 1304 KB Output is correct
10 Correct 22 ms 1236 KB Output is correct
11 Correct 32 ms 1236 KB Output is correct
12 Correct 24 ms 1304 KB Output is correct
13 Correct 25 ms 1304 KB Output is correct
14 Correct 25 ms 1300 KB Output is correct
15 Correct 30 ms 1304 KB Output is correct
16 Correct 31 ms 1236 KB Output is correct
17 Correct 17 ms 1300 KB Output is correct
18 Correct 23 ms 1300 KB Output is correct
19 Correct 26 ms 1304 KB Output is correct
20 Correct 19 ms 1236 KB Output is correct
21 Correct 43 ms 1284 KB Output is correct
22 Correct 52 ms 1236 KB Output is correct
23 Correct 36 ms 1284 KB Output is correct
24 Correct 70 ms 1284 KB Output is correct
25 Correct 59 ms 1236 KB Output is correct
26 Correct 61 ms 1300 KB Output is correct
27 Correct 63 ms 1300 KB Output is correct
28 Correct 64 ms 1288 KB Output is correct
29 Correct 61 ms 1304 KB Output is correct
30 Correct 64 ms 1308 KB Output is correct
31 Correct 62 ms 1296 KB Output is correct
32 Correct 66 ms 1284 KB Output is correct
33 Correct 63 ms 1292 KB Output is correct
34 Correct 61 ms 1292 KB Output is correct
35 Correct 62 ms 1356 KB Output is correct
36 Correct 70 ms 1296 KB Output is correct
37 Correct 129 ms 1284 KB Output is correct
38 Correct 122 ms 1288 KB Output is correct
39 Correct 181 ms 1284 KB Output is correct
40 Correct 187 ms 1412 KB Output is correct
41 Correct 202 ms 1288 KB Output is correct
42 Correct 168 ms 1292 KB Output is correct
43 Correct 163 ms 1424 KB Output is correct
44 Correct 171 ms 1416 KB Output is correct
45 Correct 168 ms 1424 KB Output is correct
46 Correct 175 ms 1288 KB Output is correct
47 Correct 172 ms 1292 KB Output is correct
48 Correct 165 ms 1292 KB Output is correct
49 Correct 174 ms 1288 KB Output is correct
50 Correct 163 ms 1292 KB Output is correct
51 Correct 167 ms 1356 KB Output is correct
52 Correct 187 ms 1412 KB Output is correct
53 Correct 192 ms 1424 KB Output is correct
54 Correct 241 ms 1420 KB Output is correct
55 Correct 259 ms 1552 KB Output is correct
56 Correct 220 ms 1424 KB Output is correct
57 Correct 258 ms 1740 KB Output is correct
58 Correct 255 ms 1544 KB Output is correct
59 Correct 240 ms 1428 KB Output is correct
60 Correct 240 ms 1412 KB Output is correct
61 Correct 243 ms 1428 KB Output is correct
62 Correct 242 ms 1560 KB Output is correct
63 Correct 234 ms 1564 KB Output is correct
64 Correct 230 ms 1668 KB Output is correct
65 Correct 222 ms 1484 KB Output is correct
66 Correct 221 ms 1416 KB Output is correct
67 Correct 284 ms 1432 KB Output is correct
68 Correct 116 ms 1288 KB Output is correct
69 Correct 425 ms 1964 KB Output is correct
70 Correct 389 ms 1692 KB Output is correct
71 Correct 381 ms 1676 KB Output is correct
72 Correct 366 ms 1432 KB Output is correct
73 Correct 393 ms 1436 KB Output is correct
74 Correct 434 ms 1956 KB Output is correct
75 Correct 394 ms 1820 KB Output is correct
76 Correct 458 ms 1868 KB Output is correct
77 Correct 474 ms 2024 KB Output is correct