Submission #994270

# Submission time Handle Problem Language Result Execution time Memory
994270 2024-06-07T10:10:44 Z VMaksimoski008 Bootfall (IZhO17_bootfall) C++17
65 / 100
371 ms 13140 KB
#include <bits/stdc++.h>

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long

using namespace std;

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
const double eps = 1e-9;
const int S = (500 * 500) / 2 + 1;

bitset<S> bs[405];

int32_t 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<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 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 9 ms 964 KB Output is correct
11 Correct 9 ms 860 KB Output is correct
12 Correct 8 ms 860 KB Output is correct
13 Correct 7 ms 860 KB Output is correct
14 Correct 8 ms 860 KB Output is correct
15 Correct 8 ms 860 KB Output is correct
16 Correct 8 ms 964 KB Output is correct
17 Correct 5 ms 688 KB Output is correct
18 Correct 7 ms 860 KB Output is correct
19 Correct 7 ms 904 KB Output is correct
20 Correct 8 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 9 ms 964 KB Output is correct
11 Correct 9 ms 860 KB Output is correct
12 Correct 8 ms 860 KB Output is correct
13 Correct 7 ms 860 KB Output is correct
14 Correct 8 ms 860 KB Output is correct
15 Correct 8 ms 860 KB Output is correct
16 Correct 8 ms 964 KB Output is correct
17 Correct 5 ms 688 KB Output is correct
18 Correct 7 ms 860 KB Output is correct
19 Correct 7 ms 904 KB Output is correct
20 Correct 8 ms 860 KB Output is correct
21 Correct 21 ms 1368 KB Output is correct
22 Correct 30 ms 1628 KB Output is correct
23 Correct 16 ms 1112 KB Output is correct
24 Correct 42 ms 1880 KB Output is correct
25 Correct 40 ms 1880 KB Output is correct
26 Correct 43 ms 1884 KB Output is correct
27 Correct 46 ms 1880 KB Output is correct
28 Correct 43 ms 1880 KB Output is correct
29 Correct 44 ms 1884 KB Output is correct
30 Correct 43 ms 1880 KB Output is correct
31 Correct 43 ms 1880 KB Output is correct
32 Correct 45 ms 2044 KB Output is correct
33 Correct 43 ms 1848 KB Output is correct
34 Correct 42 ms 1884 KB Output is correct
35 Correct 42 ms 1884 KB Output is correct
36 Correct 43 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 9 ms 964 KB Output is correct
11 Correct 9 ms 860 KB Output is correct
12 Correct 8 ms 860 KB Output is correct
13 Correct 7 ms 860 KB Output is correct
14 Correct 8 ms 860 KB Output is correct
15 Correct 8 ms 860 KB Output is correct
16 Correct 8 ms 964 KB Output is correct
17 Correct 5 ms 688 KB Output is correct
18 Correct 7 ms 860 KB Output is correct
19 Correct 7 ms 904 KB Output is correct
20 Correct 8 ms 860 KB Output is correct
21 Correct 21 ms 1368 KB Output is correct
22 Correct 30 ms 1628 KB Output is correct
23 Correct 16 ms 1112 KB Output is correct
24 Correct 42 ms 1880 KB Output is correct
25 Correct 40 ms 1880 KB Output is correct
26 Correct 43 ms 1884 KB Output is correct
27 Correct 46 ms 1880 KB Output is correct
28 Correct 43 ms 1880 KB Output is correct
29 Correct 44 ms 1884 KB Output is correct
30 Correct 43 ms 1880 KB Output is correct
31 Correct 43 ms 1880 KB Output is correct
32 Correct 45 ms 2044 KB Output is correct
33 Correct 43 ms 1848 KB Output is correct
34 Correct 42 ms 1884 KB Output is correct
35 Correct 42 ms 1884 KB Output is correct
36 Correct 43 ms 1884 KB Output is correct
37 Correct 123 ms 3672 KB Output is correct
38 Correct 120 ms 3540 KB Output is correct
39 Correct 170 ms 4176 KB Output is correct
40 Correct 196 ms 4760 KB Output is correct
41 Correct 195 ms 4432 KB Output is correct
42 Correct 170 ms 4464 KB Output is correct
43 Correct 165 ms 4432 KB Output is correct
44 Correct 169 ms 4432 KB Output is correct
45 Correct 172 ms 4592 KB Output is correct
46 Correct 188 ms 4432 KB Output is correct
47 Correct 173 ms 4432 KB Output is correct
48 Correct 170 ms 4436 KB Output is correct
49 Correct 172 ms 4156 KB Output is correct
50 Correct 169 ms 4436 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 196 ms 4984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 9 ms 964 KB Output is correct
11 Correct 9 ms 860 KB Output is correct
12 Correct 8 ms 860 KB Output is correct
13 Correct 7 ms 860 KB Output is correct
14 Correct 8 ms 860 KB Output is correct
15 Correct 8 ms 860 KB Output is correct
16 Correct 8 ms 964 KB Output is correct
17 Correct 5 ms 688 KB Output is correct
18 Correct 7 ms 860 KB Output is correct
19 Correct 7 ms 904 KB Output is correct
20 Correct 8 ms 860 KB Output is correct
21 Correct 21 ms 1368 KB Output is correct
22 Correct 30 ms 1628 KB Output is correct
23 Correct 16 ms 1112 KB Output is correct
24 Correct 42 ms 1880 KB Output is correct
25 Correct 40 ms 1880 KB Output is correct
26 Correct 43 ms 1884 KB Output is correct
27 Correct 46 ms 1880 KB Output is correct
28 Correct 43 ms 1880 KB Output is correct
29 Correct 44 ms 1884 KB Output is correct
30 Correct 43 ms 1880 KB Output is correct
31 Correct 43 ms 1880 KB Output is correct
32 Correct 45 ms 2044 KB Output is correct
33 Correct 43 ms 1848 KB Output is correct
34 Correct 42 ms 1884 KB Output is correct
35 Correct 42 ms 1884 KB Output is correct
36 Correct 43 ms 1884 KB Output is correct
37 Correct 123 ms 3672 KB Output is correct
38 Correct 120 ms 3540 KB Output is correct
39 Correct 170 ms 4176 KB Output is correct
40 Correct 196 ms 4760 KB Output is correct
41 Correct 195 ms 4432 KB Output is correct
42 Correct 170 ms 4464 KB Output is correct
43 Correct 165 ms 4432 KB Output is correct
44 Correct 169 ms 4432 KB Output is correct
45 Correct 172 ms 4592 KB Output is correct
46 Correct 188 ms 4432 KB Output is correct
47 Correct 173 ms 4432 KB Output is correct
48 Correct 170 ms 4436 KB Output is correct
49 Correct 172 ms 4156 KB Output is correct
50 Correct 169 ms 4436 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 196 ms 4984 KB Output is correct
53 Correct 228 ms 5200 KB Output is correct
54 Correct 296 ms 6228 KB Output is correct
55 Correct 296 ms 6356 KB Output is correct
56 Correct 238 ms 5456 KB Output is correct
57 Correct 297 ms 6424 KB Output is correct
58 Correct 303 ms 6136 KB Output is correct
59 Correct 312 ms 6224 KB Output is correct
60 Correct 1 ms 344 KB Output is correct
61 Correct 298 ms 6248 KB Output is correct
62 Correct 259 ms 5844 KB Output is correct
63 Correct 264 ms 5848 KB Output is correct
64 Correct 252 ms 5848 KB Output is correct
65 Correct 247 ms 5200 KB Output is correct
66 Correct 239 ms 5204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 3 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 3 ms 604 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 9 ms 964 KB Output is correct
11 Correct 9 ms 860 KB Output is correct
12 Correct 8 ms 860 KB Output is correct
13 Correct 7 ms 860 KB Output is correct
14 Correct 8 ms 860 KB Output is correct
15 Correct 8 ms 860 KB Output is correct
16 Correct 8 ms 964 KB Output is correct
17 Correct 5 ms 688 KB Output is correct
18 Correct 7 ms 860 KB Output is correct
19 Correct 7 ms 904 KB Output is correct
20 Correct 8 ms 860 KB Output is correct
21 Correct 21 ms 1368 KB Output is correct
22 Correct 30 ms 1628 KB Output is correct
23 Correct 16 ms 1112 KB Output is correct
24 Correct 42 ms 1880 KB Output is correct
25 Correct 40 ms 1880 KB Output is correct
26 Correct 43 ms 1884 KB Output is correct
27 Correct 46 ms 1880 KB Output is correct
28 Correct 43 ms 1880 KB Output is correct
29 Correct 44 ms 1884 KB Output is correct
30 Correct 43 ms 1880 KB Output is correct
31 Correct 43 ms 1880 KB Output is correct
32 Correct 45 ms 2044 KB Output is correct
33 Correct 43 ms 1848 KB Output is correct
34 Correct 42 ms 1884 KB Output is correct
35 Correct 42 ms 1884 KB Output is correct
36 Correct 43 ms 1884 KB Output is correct
37 Correct 123 ms 3672 KB Output is correct
38 Correct 120 ms 3540 KB Output is correct
39 Correct 170 ms 4176 KB Output is correct
40 Correct 196 ms 4760 KB Output is correct
41 Correct 195 ms 4432 KB Output is correct
42 Correct 170 ms 4464 KB Output is correct
43 Correct 165 ms 4432 KB Output is correct
44 Correct 169 ms 4432 KB Output is correct
45 Correct 172 ms 4592 KB Output is correct
46 Correct 188 ms 4432 KB Output is correct
47 Correct 173 ms 4432 KB Output is correct
48 Correct 170 ms 4436 KB Output is correct
49 Correct 172 ms 4156 KB Output is correct
50 Correct 169 ms 4436 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 196 ms 4984 KB Output is correct
53 Correct 228 ms 5200 KB Output is correct
54 Correct 296 ms 6228 KB Output is correct
55 Correct 296 ms 6356 KB Output is correct
56 Correct 238 ms 5456 KB Output is correct
57 Correct 297 ms 6424 KB Output is correct
58 Correct 303 ms 6136 KB Output is correct
59 Correct 312 ms 6224 KB Output is correct
60 Correct 1 ms 344 KB Output is correct
61 Correct 298 ms 6248 KB Output is correct
62 Correct 259 ms 5844 KB Output is correct
63 Correct 264 ms 5848 KB Output is correct
64 Correct 252 ms 5848 KB Output is correct
65 Correct 247 ms 5200 KB Output is correct
66 Correct 239 ms 5204 KB Output is correct
67 Correct 371 ms 7124 KB Output is correct
68 Correct 1 ms 348 KB Output is correct
69 Runtime error 343 ms 13140 KB Execution killed with signal 11
70 Halted 0 ms 0 KB -