Submission #994282

# Submission time Handle Problem Language Result Execution time Memory
994282 2024-06-07T10:16:34 Z VMaksimoski008 Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 15988 KB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx,bmi,bmi2,lzcnt,popcnt")

const int S = (500 * 500) + 1;

bitset<S> bs[501];

int main() {
    ios_base::sync_with_stdio(false);
    cout.tie(0); cin.tie(0);

    int n, sum = 0;
    cin >> n;

    vector<int> v(n);
    bs[0][0] = 1;
    for(int &x : v) {
        cin >> x;
        sum += x;
        bs[0] |= (bs[0] << x);
    }

    if(sum % 2 == 1 || !bs[0][sum/2]) {
        cout << 0 << '\n';
        return 0;
    }

    for(int i=0; i<n; i++) {
        bs[i+1][0] = 1;
        for(int j=0; j<n; j++)
            if(i != j) bs[i+1] |= (bs[i+1] << v[j]);
        // cout << i << ": ";
        // for(int j=0; j<=10; j++) if(bs[i+1][j]) cout << j << " ";
        // cout << '\n';
    }

    vector<int> ans;

    for(int j=1; j<min(sum, S); j++) {
        bool ok = 1;
        for(int i=1; i<=n; i++) {
            if( (sum - v[i-1] + j) % 2 == 1 ) ok = 0;
            if( (bs[i][(sum - v[i-1] + j) / 2]) == 0 ) ok = 0;
        }
        if(ok) ans.push_back(j);
    }

    cout << ans.size() << '\n';
    for(int &x : ans) cout << x << " ";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 5 ms 1368 KB Output is correct
11 Correct 5 ms 1372 KB Output is correct
12 Correct 4 ms 1372 KB Output is correct
13 Correct 4 ms 1196 KB Output is correct
14 Correct 4 ms 1372 KB Output is correct
15 Correct 4 ms 1372 KB Output is correct
16 Correct 5 ms 1372 KB Output is correct
17 Correct 2 ms 860 KB Output is correct
18 Correct 3 ms 1232 KB Output is correct
19 Correct 3 ms 1116 KB Output is correct
20 Correct 4 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 5 ms 1368 KB Output is correct
11 Correct 5 ms 1372 KB Output is correct
12 Correct 4 ms 1372 KB Output is correct
13 Correct 4 ms 1196 KB Output is correct
14 Correct 4 ms 1372 KB Output is correct
15 Correct 4 ms 1372 KB Output is correct
16 Correct 5 ms 1372 KB Output is correct
17 Correct 2 ms 860 KB Output is correct
18 Correct 3 ms 1232 KB Output is correct
19 Correct 3 ms 1116 KB Output is correct
20 Correct 4 ms 1372 KB Output is correct
21 Correct 20 ms 2396 KB Output is correct
22 Correct 23 ms 2648 KB Output is correct
23 Correct 11 ms 1884 KB Output is correct
24 Correct 37 ms 3348 KB Output is correct
25 Correct 38 ms 3408 KB Output is correct
26 Correct 42 ms 3572 KB Output is correct
27 Correct 43 ms 3440 KB Output is correct
28 Correct 43 ms 3508 KB Output is correct
29 Correct 49 ms 3392 KB Output is correct
30 Correct 40 ms 3408 KB Output is correct
31 Correct 43 ms 3412 KB Output is correct
32 Correct 41 ms 3412 KB Output is correct
33 Correct 43 ms 3528 KB Output is correct
34 Correct 41 ms 3412 KB Output is correct
35 Correct 48 ms 3412 KB Output is correct
36 Correct 42 ms 3568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 5 ms 1368 KB Output is correct
11 Correct 5 ms 1372 KB Output is correct
12 Correct 4 ms 1372 KB Output is correct
13 Correct 4 ms 1196 KB Output is correct
14 Correct 4 ms 1372 KB Output is correct
15 Correct 4 ms 1372 KB Output is correct
16 Correct 5 ms 1372 KB Output is correct
17 Correct 2 ms 860 KB Output is correct
18 Correct 3 ms 1232 KB Output is correct
19 Correct 3 ms 1116 KB Output is correct
20 Correct 4 ms 1372 KB Output is correct
21 Correct 20 ms 2396 KB Output is correct
22 Correct 23 ms 2648 KB Output is correct
23 Correct 11 ms 1884 KB Output is correct
24 Correct 37 ms 3348 KB Output is correct
25 Correct 38 ms 3408 KB Output is correct
26 Correct 42 ms 3572 KB Output is correct
27 Correct 43 ms 3440 KB Output is correct
28 Correct 43 ms 3508 KB Output is correct
29 Correct 49 ms 3392 KB Output is correct
30 Correct 40 ms 3408 KB Output is correct
31 Correct 43 ms 3412 KB Output is correct
32 Correct 41 ms 3412 KB Output is correct
33 Correct 43 ms 3528 KB Output is correct
34 Correct 41 ms 3412 KB Output is correct
35 Correct 48 ms 3412 KB Output is correct
36 Correct 42 ms 3568 KB Output is correct
37 Correct 166 ms 6752 KB Output is correct
38 Correct 167 ms 6584 KB Output is correct
39 Correct 281 ms 7888 KB Output is correct
40 Correct 311 ms 8784 KB Output is correct
41 Correct 334 ms 8724 KB Output is correct
42 Correct 267 ms 8276 KB Output is correct
43 Correct 268 ms 8272 KB Output is correct
44 Correct 288 ms 8368 KB Output is correct
45 Correct 293 ms 8420 KB Output is correct
46 Correct 324 ms 8788 KB Output is correct
47 Correct 270 ms 8328 KB Output is correct
48 Correct 294 ms 8344 KB Output is correct
49 Correct 298 ms 8068 KB Output is correct
50 Correct 275 ms 8276 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 345 ms 9036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 5 ms 1368 KB Output is correct
11 Correct 5 ms 1372 KB Output is correct
12 Correct 4 ms 1372 KB Output is correct
13 Correct 4 ms 1196 KB Output is correct
14 Correct 4 ms 1372 KB Output is correct
15 Correct 4 ms 1372 KB Output is correct
16 Correct 5 ms 1372 KB Output is correct
17 Correct 2 ms 860 KB Output is correct
18 Correct 3 ms 1232 KB Output is correct
19 Correct 3 ms 1116 KB Output is correct
20 Correct 4 ms 1372 KB Output is correct
21 Correct 20 ms 2396 KB Output is correct
22 Correct 23 ms 2648 KB Output is correct
23 Correct 11 ms 1884 KB Output is correct
24 Correct 37 ms 3348 KB Output is correct
25 Correct 38 ms 3408 KB Output is correct
26 Correct 42 ms 3572 KB Output is correct
27 Correct 43 ms 3440 KB Output is correct
28 Correct 43 ms 3508 KB Output is correct
29 Correct 49 ms 3392 KB Output is correct
30 Correct 40 ms 3408 KB Output is correct
31 Correct 43 ms 3412 KB Output is correct
32 Correct 41 ms 3412 KB Output is correct
33 Correct 43 ms 3528 KB Output is correct
34 Correct 41 ms 3412 KB Output is correct
35 Correct 48 ms 3412 KB Output is correct
36 Correct 42 ms 3568 KB Output is correct
37 Correct 166 ms 6752 KB Output is correct
38 Correct 167 ms 6584 KB Output is correct
39 Correct 281 ms 7888 KB Output is correct
40 Correct 311 ms 8784 KB Output is correct
41 Correct 334 ms 8724 KB Output is correct
42 Correct 267 ms 8276 KB Output is correct
43 Correct 268 ms 8272 KB Output is correct
44 Correct 288 ms 8368 KB Output is correct
45 Correct 293 ms 8420 KB Output is correct
46 Correct 324 ms 8788 KB Output is correct
47 Correct 270 ms 8328 KB Output is correct
48 Correct 294 ms 8344 KB Output is correct
49 Correct 298 ms 8068 KB Output is correct
50 Correct 275 ms 8276 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 345 ms 9036 KB Output is correct
53 Correct 406 ms 9840 KB Output is correct
54 Correct 532 ms 11612 KB Output is correct
55 Correct 582 ms 11736 KB Output is correct
56 Correct 420 ms 10068 KB Output is correct
57 Correct 586 ms 11832 KB Output is correct
58 Correct 537 ms 11528 KB Output is correct
59 Correct 550 ms 11736 KB Output is correct
60 Correct 2 ms 348 KB Output is correct
61 Correct 563 ms 11748 KB Output is correct
62 Correct 486 ms 10712 KB Output is correct
63 Correct 499 ms 10764 KB Output is correct
64 Correct 485 ms 10708 KB Output is correct
65 Correct 429 ms 10168 KB Output is correct
66 Correct 423 ms 9852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 5 ms 1368 KB Output is correct
11 Correct 5 ms 1372 KB Output is correct
12 Correct 4 ms 1372 KB Output is correct
13 Correct 4 ms 1196 KB Output is correct
14 Correct 4 ms 1372 KB Output is correct
15 Correct 4 ms 1372 KB Output is correct
16 Correct 5 ms 1372 KB Output is correct
17 Correct 2 ms 860 KB Output is correct
18 Correct 3 ms 1232 KB Output is correct
19 Correct 3 ms 1116 KB Output is correct
20 Correct 4 ms 1372 KB Output is correct
21 Correct 20 ms 2396 KB Output is correct
22 Correct 23 ms 2648 KB Output is correct
23 Correct 11 ms 1884 KB Output is correct
24 Correct 37 ms 3348 KB Output is correct
25 Correct 38 ms 3408 KB Output is correct
26 Correct 42 ms 3572 KB Output is correct
27 Correct 43 ms 3440 KB Output is correct
28 Correct 43 ms 3508 KB Output is correct
29 Correct 49 ms 3392 KB Output is correct
30 Correct 40 ms 3408 KB Output is correct
31 Correct 43 ms 3412 KB Output is correct
32 Correct 41 ms 3412 KB Output is correct
33 Correct 43 ms 3528 KB Output is correct
34 Correct 41 ms 3412 KB Output is correct
35 Correct 48 ms 3412 KB Output is correct
36 Correct 42 ms 3568 KB Output is correct
37 Correct 166 ms 6752 KB Output is correct
38 Correct 167 ms 6584 KB Output is correct
39 Correct 281 ms 7888 KB Output is correct
40 Correct 311 ms 8784 KB Output is correct
41 Correct 334 ms 8724 KB Output is correct
42 Correct 267 ms 8276 KB Output is correct
43 Correct 268 ms 8272 KB Output is correct
44 Correct 288 ms 8368 KB Output is correct
45 Correct 293 ms 8420 KB Output is correct
46 Correct 324 ms 8788 KB Output is correct
47 Correct 270 ms 8328 KB Output is correct
48 Correct 294 ms 8344 KB Output is correct
49 Correct 298 ms 8068 KB Output is correct
50 Correct 275 ms 8276 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 345 ms 9036 KB Output is correct
53 Correct 406 ms 9840 KB Output is correct
54 Correct 532 ms 11612 KB Output is correct
55 Correct 582 ms 11736 KB Output is correct
56 Correct 420 ms 10068 KB Output is correct
57 Correct 586 ms 11832 KB Output is correct
58 Correct 537 ms 11528 KB Output is correct
59 Correct 550 ms 11736 KB Output is correct
60 Correct 2 ms 348 KB Output is correct
61 Correct 563 ms 11748 KB Output is correct
62 Correct 486 ms 10712 KB Output is correct
63 Correct 499 ms 10764 KB Output is correct
64 Correct 485 ms 10708 KB Output is correct
65 Correct 429 ms 10168 KB Output is correct
66 Correct 423 ms 9852 KB Output is correct
67 Correct 706 ms 13104 KB Output is correct
68 Correct 3 ms 344 KB Output is correct
69 Execution timed out 1076 ms 15988 KB Time limit exceeded
70 Halted 0 ms 0 KB -