답안 #947606

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
947606 2024-03-16T14:59:22 Z Pring Bootfall (IZhO17_bootfall) C++17
100 / 100
934 ms 17748 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3","unroll-loops")
#pragma GCC target("avx2","popcnt")
using namespace std;

#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

#define int long long
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
typedef pair<int, int> pii;

const int MXN = 250005;
int n, a[MXN];
int sum;
bitset<MXN> ans, b, c;
bitset<MXN> p[505];

bool check() {
    if (sum & 1) return false;
    ans.reset();
    ans[0] = true;
    FOR(i, 0, n) ans |= (ans << a[i]);
    return ans[sum / 2];
}

void miku() {
    cin >> n;
    FOR(i, 0, n) cin >> a[i];
    FOR(i, 0, n) sum += a[i];
    if (!check()) {
        cout << 0 << '\n' << '\n';
        return;
    }
    ans.set();
    p[0][0] = 1;
    FOR(i, 0, n) p[i + 1] = p[i] | (p[i] << a[i]);
    FOR(i, 0, n) {
        c.reset();
        b = p[i];
        FOR(j, i + 1, n) b |= (b << a[j]);
        FOR(j, 0, sum - a[i] + 1) if (b[j]) c[abs(sum - a[i] - 2 * j)] = true;
        ans &= c;
    }
    cout << ans.count() << '\n';
    FOR(i, 0, MXN) if (ans[i]) cout << i << ' ';
    cout << '\n';
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    miku();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 4700 KB Output is correct
6 Correct 1 ms 4748 KB Output is correct
7 Correct 1 ms 4696 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 2 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 4700 KB Output is correct
6 Correct 1 ms 4748 KB Output is correct
7 Correct 1 ms 4696 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 2 ms 4700 KB Output is correct
10 Correct 4 ms 4700 KB Output is correct
11 Correct 4 ms 4616 KB Output is correct
12 Correct 4 ms 4700 KB Output is correct
13 Correct 3 ms 4832 KB Output is correct
14 Correct 4 ms 4700 KB Output is correct
15 Correct 4 ms 4700 KB Output is correct
16 Correct 4 ms 4700 KB Output is correct
17 Correct 2 ms 4696 KB Output is correct
18 Correct 3 ms 4952 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 4 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 4700 KB Output is correct
6 Correct 1 ms 4748 KB Output is correct
7 Correct 1 ms 4696 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 2 ms 4700 KB Output is correct
10 Correct 4 ms 4700 KB Output is correct
11 Correct 4 ms 4616 KB Output is correct
12 Correct 4 ms 4700 KB Output is correct
13 Correct 3 ms 4832 KB Output is correct
14 Correct 4 ms 4700 KB Output is correct
15 Correct 4 ms 4700 KB Output is correct
16 Correct 4 ms 4700 KB Output is correct
17 Correct 2 ms 4696 KB Output is correct
18 Correct 3 ms 4952 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 4 ms 4700 KB Output is correct
21 Correct 14 ms 4696 KB Output is correct
22 Correct 18 ms 6748 KB Output is correct
23 Correct 9 ms 4700 KB Output is correct
24 Correct 28 ms 6748 KB Output is correct
25 Correct 28 ms 7000 KB Output is correct
26 Correct 32 ms 6748 KB Output is correct
27 Correct 32 ms 6880 KB Output is correct
28 Correct 32 ms 6744 KB Output is correct
29 Correct 31 ms 6884 KB Output is correct
30 Correct 31 ms 6748 KB Output is correct
31 Correct 32 ms 6744 KB Output is correct
32 Correct 31 ms 7128 KB Output is correct
33 Correct 31 ms 6744 KB Output is correct
34 Correct 32 ms 6748 KB Output is correct
35 Correct 32 ms 6748 KB Output is correct
36 Correct 31 ms 6872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 4700 KB Output is correct
6 Correct 1 ms 4748 KB Output is correct
7 Correct 1 ms 4696 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 2 ms 4700 KB Output is correct
10 Correct 4 ms 4700 KB Output is correct
11 Correct 4 ms 4616 KB Output is correct
12 Correct 4 ms 4700 KB Output is correct
13 Correct 3 ms 4832 KB Output is correct
14 Correct 4 ms 4700 KB Output is correct
15 Correct 4 ms 4700 KB Output is correct
16 Correct 4 ms 4700 KB Output is correct
17 Correct 2 ms 4696 KB Output is correct
18 Correct 3 ms 4952 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 4 ms 4700 KB Output is correct
21 Correct 14 ms 4696 KB Output is correct
22 Correct 18 ms 6748 KB Output is correct
23 Correct 9 ms 4700 KB Output is correct
24 Correct 28 ms 6748 KB Output is correct
25 Correct 28 ms 7000 KB Output is correct
26 Correct 32 ms 6748 KB Output is correct
27 Correct 32 ms 6880 KB Output is correct
28 Correct 32 ms 6744 KB Output is correct
29 Correct 31 ms 6884 KB Output is correct
30 Correct 31 ms 6748 KB Output is correct
31 Correct 32 ms 6744 KB Output is correct
32 Correct 31 ms 7128 KB Output is correct
33 Correct 31 ms 6744 KB Output is correct
34 Correct 32 ms 6748 KB Output is correct
35 Correct 32 ms 6748 KB Output is correct
36 Correct 31 ms 6872 KB Output is correct
37 Correct 124 ms 8928 KB Output is correct
38 Correct 127 ms 9048 KB Output is correct
39 Correct 188 ms 10968 KB Output is correct
40 Correct 233 ms 10980 KB Output is correct
41 Correct 225 ms 10980 KB Output is correct
42 Correct 198 ms 10960 KB Output is correct
43 Correct 202 ms 10964 KB Output is correct
44 Correct 206 ms 10964 KB Output is correct
45 Correct 204 ms 10964 KB Output is correct
46 Correct 218 ms 10840 KB Output is correct
47 Correct 193 ms 10976 KB Output is correct
48 Correct 206 ms 10968 KB Output is correct
49 Correct 198 ms 10960 KB Output is correct
50 Correct 194 ms 10964 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 239 ms 10984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 4700 KB Output is correct
6 Correct 1 ms 4748 KB Output is correct
7 Correct 1 ms 4696 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 2 ms 4700 KB Output is correct
10 Correct 4 ms 4700 KB Output is correct
11 Correct 4 ms 4616 KB Output is correct
12 Correct 4 ms 4700 KB Output is correct
13 Correct 3 ms 4832 KB Output is correct
14 Correct 4 ms 4700 KB Output is correct
15 Correct 4 ms 4700 KB Output is correct
16 Correct 4 ms 4700 KB Output is correct
17 Correct 2 ms 4696 KB Output is correct
18 Correct 3 ms 4952 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 4 ms 4700 KB Output is correct
21 Correct 14 ms 4696 KB Output is correct
22 Correct 18 ms 6748 KB Output is correct
23 Correct 9 ms 4700 KB Output is correct
24 Correct 28 ms 6748 KB Output is correct
25 Correct 28 ms 7000 KB Output is correct
26 Correct 32 ms 6748 KB Output is correct
27 Correct 32 ms 6880 KB Output is correct
28 Correct 32 ms 6744 KB Output is correct
29 Correct 31 ms 6884 KB Output is correct
30 Correct 31 ms 6748 KB Output is correct
31 Correct 32 ms 6744 KB Output is correct
32 Correct 31 ms 7128 KB Output is correct
33 Correct 31 ms 6744 KB Output is correct
34 Correct 32 ms 6748 KB Output is correct
35 Correct 32 ms 6748 KB Output is correct
36 Correct 31 ms 6872 KB Output is correct
37 Correct 124 ms 8928 KB Output is correct
38 Correct 127 ms 9048 KB Output is correct
39 Correct 188 ms 10968 KB Output is correct
40 Correct 233 ms 10980 KB Output is correct
41 Correct 225 ms 10980 KB Output is correct
42 Correct 198 ms 10960 KB Output is correct
43 Correct 202 ms 10964 KB Output is correct
44 Correct 206 ms 10964 KB Output is correct
45 Correct 204 ms 10964 KB Output is correct
46 Correct 218 ms 10840 KB Output is correct
47 Correct 193 ms 10976 KB Output is correct
48 Correct 206 ms 10968 KB Output is correct
49 Correct 198 ms 10960 KB Output is correct
50 Correct 194 ms 10964 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 239 ms 10984 KB Output is correct
53 Correct 280 ms 13020 KB Output is correct
54 Correct 395 ms 15076 KB Output is correct
55 Correct 417 ms 15444 KB Output is correct
56 Correct 308 ms 13020 KB Output is correct
57 Correct 419 ms 15328 KB Output is correct
58 Correct 392 ms 15184 KB Output is correct
59 Correct 396 ms 15076 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 404 ms 15088 KB Output is correct
62 Correct 344 ms 13140 KB Output is correct
63 Correct 357 ms 13396 KB Output is correct
64 Correct 344 ms 13288 KB Output is correct
65 Correct 294 ms 12888 KB Output is correct
66 Correct 286 ms 12888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 2 ms 4700 KB Output is correct
6 Correct 1 ms 4748 KB Output is correct
7 Correct 1 ms 4696 KB Output is correct
8 Correct 2 ms 4700 KB Output is correct
9 Correct 2 ms 4700 KB Output is correct
10 Correct 4 ms 4700 KB Output is correct
11 Correct 4 ms 4616 KB Output is correct
12 Correct 4 ms 4700 KB Output is correct
13 Correct 3 ms 4832 KB Output is correct
14 Correct 4 ms 4700 KB Output is correct
15 Correct 4 ms 4700 KB Output is correct
16 Correct 4 ms 4700 KB Output is correct
17 Correct 2 ms 4696 KB Output is correct
18 Correct 3 ms 4952 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 4 ms 4700 KB Output is correct
21 Correct 14 ms 4696 KB Output is correct
22 Correct 18 ms 6748 KB Output is correct
23 Correct 9 ms 4700 KB Output is correct
24 Correct 28 ms 6748 KB Output is correct
25 Correct 28 ms 7000 KB Output is correct
26 Correct 32 ms 6748 KB Output is correct
27 Correct 32 ms 6880 KB Output is correct
28 Correct 32 ms 6744 KB Output is correct
29 Correct 31 ms 6884 KB Output is correct
30 Correct 31 ms 6748 KB Output is correct
31 Correct 32 ms 6744 KB Output is correct
32 Correct 31 ms 7128 KB Output is correct
33 Correct 31 ms 6744 KB Output is correct
34 Correct 32 ms 6748 KB Output is correct
35 Correct 32 ms 6748 KB Output is correct
36 Correct 31 ms 6872 KB Output is correct
37 Correct 124 ms 8928 KB Output is correct
38 Correct 127 ms 9048 KB Output is correct
39 Correct 188 ms 10968 KB Output is correct
40 Correct 233 ms 10980 KB Output is correct
41 Correct 225 ms 10980 KB Output is correct
42 Correct 198 ms 10960 KB Output is correct
43 Correct 202 ms 10964 KB Output is correct
44 Correct 206 ms 10964 KB Output is correct
45 Correct 204 ms 10964 KB Output is correct
46 Correct 218 ms 10840 KB Output is correct
47 Correct 193 ms 10976 KB Output is correct
48 Correct 206 ms 10968 KB Output is correct
49 Correct 198 ms 10960 KB Output is correct
50 Correct 194 ms 10964 KB Output is correct
51 Correct 1 ms 2396 KB Output is correct
52 Correct 239 ms 10984 KB Output is correct
53 Correct 280 ms 13020 KB Output is correct
54 Correct 395 ms 15076 KB Output is correct
55 Correct 417 ms 15444 KB Output is correct
56 Correct 308 ms 13020 KB Output is correct
57 Correct 419 ms 15328 KB Output is correct
58 Correct 392 ms 15184 KB Output is correct
59 Correct 396 ms 15076 KB Output is correct
60 Correct 1 ms 2396 KB Output is correct
61 Correct 404 ms 15088 KB Output is correct
62 Correct 344 ms 13140 KB Output is correct
63 Correct 357 ms 13396 KB Output is correct
64 Correct 344 ms 13288 KB Output is correct
65 Correct 294 ms 12888 KB Output is correct
66 Correct 286 ms 12888 KB Output is correct
67 Correct 512 ms 15072 KB Output is correct
68 Correct 3 ms 2396 KB Output is correct
69 Correct 914 ms 17648 KB Output is correct
70 Correct 834 ms 17492 KB Output is correct
71 Correct 832 ms 17492 KB Output is correct
72 Correct 827 ms 17116 KB Output is correct
73 Correct 855 ms 17124 KB Output is correct
74 Correct 908 ms 17636 KB Output is correct
75 Correct 865 ms 17748 KB Output is correct
76 Correct 934 ms 17748 KB Output is correct
77 Correct 923 ms 17628 KB Output is correct