답안 #947603

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
947603 2024-03-16T14:50:53 Z Pring Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 920 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;

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();
    FOR(i, 0, n) {
        b.reset();
        c.reset();
        b[0] = true;
        FOR(j, 0, n) {
            if (j == i) continue;
            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 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 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 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 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 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 6 ms 604 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 4 ms 672 KB Output is correct
14 Correct 5 ms 604 KB Output is correct
15 Correct 5 ms 604 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 4 ms 604 KB Output is correct
19 Correct 5 ms 672 KB Output is correct
20 Correct 6 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 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 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 6 ms 604 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 4 ms 672 KB Output is correct
14 Correct 5 ms 604 KB Output is correct
15 Correct 5 ms 604 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 4 ms 604 KB Output is correct
19 Correct 5 ms 672 KB Output is correct
20 Correct 6 ms 604 KB Output is correct
21 Correct 24 ms 604 KB Output is correct
22 Correct 33 ms 604 KB Output is correct
23 Correct 15 ms 604 KB Output is correct
24 Correct 52 ms 648 KB Output is correct
25 Correct 53 ms 648 KB Output is correct
26 Correct 60 ms 604 KB Output is correct
27 Correct 57 ms 604 KB Output is correct
28 Correct 57 ms 856 KB Output is correct
29 Correct 57 ms 604 KB Output is correct
30 Correct 58 ms 604 KB Output is correct
31 Correct 58 ms 652 KB Output is correct
32 Correct 57 ms 652 KB Output is correct
33 Correct 57 ms 652 KB Output is correct
34 Correct 57 ms 604 KB Output is correct
35 Correct 62 ms 604 KB Output is correct
36 Correct 57 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 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 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 6 ms 604 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 4 ms 672 KB Output is correct
14 Correct 5 ms 604 KB Output is correct
15 Correct 5 ms 604 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 4 ms 604 KB Output is correct
19 Correct 5 ms 672 KB Output is correct
20 Correct 6 ms 604 KB Output is correct
21 Correct 24 ms 604 KB Output is correct
22 Correct 33 ms 604 KB Output is correct
23 Correct 15 ms 604 KB Output is correct
24 Correct 52 ms 648 KB Output is correct
25 Correct 53 ms 648 KB Output is correct
26 Correct 60 ms 604 KB Output is correct
27 Correct 57 ms 604 KB Output is correct
28 Correct 57 ms 856 KB Output is correct
29 Correct 57 ms 604 KB Output is correct
30 Correct 58 ms 604 KB Output is correct
31 Correct 58 ms 652 KB Output is correct
32 Correct 57 ms 652 KB Output is correct
33 Correct 57 ms 652 KB Output is correct
34 Correct 57 ms 604 KB Output is correct
35 Correct 62 ms 604 KB Output is correct
36 Correct 57 ms 600 KB Output is correct
37 Correct 234 ms 668 KB Output is correct
38 Correct 231 ms 604 KB Output is correct
39 Correct 351 ms 652 KB Output is correct
40 Correct 431 ms 652 KB Output is correct
41 Correct 424 ms 648 KB Output is correct
42 Correct 359 ms 600 KB Output is correct
43 Correct 353 ms 652 KB Output is correct
44 Correct 375 ms 652 KB Output is correct
45 Correct 381 ms 604 KB Output is correct
46 Correct 421 ms 852 KB Output is correct
47 Correct 380 ms 652 KB Output is correct
48 Correct 384 ms 648 KB Output is correct
49 Correct 363 ms 604 KB Output is correct
50 Correct 364 ms 648 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 469 ms 656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 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 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 6 ms 604 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 4 ms 672 KB Output is correct
14 Correct 5 ms 604 KB Output is correct
15 Correct 5 ms 604 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 4 ms 604 KB Output is correct
19 Correct 5 ms 672 KB Output is correct
20 Correct 6 ms 604 KB Output is correct
21 Correct 24 ms 604 KB Output is correct
22 Correct 33 ms 604 KB Output is correct
23 Correct 15 ms 604 KB Output is correct
24 Correct 52 ms 648 KB Output is correct
25 Correct 53 ms 648 KB Output is correct
26 Correct 60 ms 604 KB Output is correct
27 Correct 57 ms 604 KB Output is correct
28 Correct 57 ms 856 KB Output is correct
29 Correct 57 ms 604 KB Output is correct
30 Correct 58 ms 604 KB Output is correct
31 Correct 58 ms 652 KB Output is correct
32 Correct 57 ms 652 KB Output is correct
33 Correct 57 ms 652 KB Output is correct
34 Correct 57 ms 604 KB Output is correct
35 Correct 62 ms 604 KB Output is correct
36 Correct 57 ms 600 KB Output is correct
37 Correct 234 ms 668 KB Output is correct
38 Correct 231 ms 604 KB Output is correct
39 Correct 351 ms 652 KB Output is correct
40 Correct 431 ms 652 KB Output is correct
41 Correct 424 ms 648 KB Output is correct
42 Correct 359 ms 600 KB Output is correct
43 Correct 353 ms 652 KB Output is correct
44 Correct 375 ms 652 KB Output is correct
45 Correct 381 ms 604 KB Output is correct
46 Correct 421 ms 852 KB Output is correct
47 Correct 380 ms 652 KB Output is correct
48 Correct 384 ms 648 KB Output is correct
49 Correct 363 ms 604 KB Output is correct
50 Correct 364 ms 648 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 469 ms 656 KB Output is correct
53 Correct 573 ms 652 KB Output is correct
54 Correct 738 ms 648 KB Output is correct
55 Correct 751 ms 904 KB Output is correct
56 Correct 553 ms 652 KB Output is correct
57 Correct 766 ms 908 KB Output is correct
58 Correct 746 ms 652 KB Output is correct
59 Correct 766 ms 648 KB Output is correct
60 Correct 1 ms 344 KB Output is correct
61 Correct 735 ms 848 KB Output is correct
62 Correct 642 ms 908 KB Output is correct
63 Correct 640 ms 900 KB Output is correct
64 Correct 625 ms 920 KB Output is correct
65 Correct 583 ms 648 KB Output is correct
66 Correct 560 ms 648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 604 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 604 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 6 ms 604 KB Output is correct
11 Correct 6 ms 604 KB Output is correct
12 Correct 6 ms 604 KB Output is correct
13 Correct 4 ms 672 KB Output is correct
14 Correct 5 ms 604 KB Output is correct
15 Correct 5 ms 604 KB Output is correct
16 Correct 7 ms 600 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 4 ms 604 KB Output is correct
19 Correct 5 ms 672 KB Output is correct
20 Correct 6 ms 604 KB Output is correct
21 Correct 24 ms 604 KB Output is correct
22 Correct 33 ms 604 KB Output is correct
23 Correct 15 ms 604 KB Output is correct
24 Correct 52 ms 648 KB Output is correct
25 Correct 53 ms 648 KB Output is correct
26 Correct 60 ms 604 KB Output is correct
27 Correct 57 ms 604 KB Output is correct
28 Correct 57 ms 856 KB Output is correct
29 Correct 57 ms 604 KB Output is correct
30 Correct 58 ms 604 KB Output is correct
31 Correct 58 ms 652 KB Output is correct
32 Correct 57 ms 652 KB Output is correct
33 Correct 57 ms 652 KB Output is correct
34 Correct 57 ms 604 KB Output is correct
35 Correct 62 ms 604 KB Output is correct
36 Correct 57 ms 600 KB Output is correct
37 Correct 234 ms 668 KB Output is correct
38 Correct 231 ms 604 KB Output is correct
39 Correct 351 ms 652 KB Output is correct
40 Correct 431 ms 652 KB Output is correct
41 Correct 424 ms 648 KB Output is correct
42 Correct 359 ms 600 KB Output is correct
43 Correct 353 ms 652 KB Output is correct
44 Correct 375 ms 652 KB Output is correct
45 Correct 381 ms 604 KB Output is correct
46 Correct 421 ms 852 KB Output is correct
47 Correct 380 ms 652 KB Output is correct
48 Correct 384 ms 648 KB Output is correct
49 Correct 363 ms 604 KB Output is correct
50 Correct 364 ms 648 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 469 ms 656 KB Output is correct
53 Correct 573 ms 652 KB Output is correct
54 Correct 738 ms 648 KB Output is correct
55 Correct 751 ms 904 KB Output is correct
56 Correct 553 ms 652 KB Output is correct
57 Correct 766 ms 908 KB Output is correct
58 Correct 746 ms 652 KB Output is correct
59 Correct 766 ms 648 KB Output is correct
60 Correct 1 ms 344 KB Output is correct
61 Correct 735 ms 848 KB Output is correct
62 Correct 642 ms 908 KB Output is correct
63 Correct 640 ms 900 KB Output is correct
64 Correct 625 ms 920 KB Output is correct
65 Correct 583 ms 648 KB Output is correct
66 Correct 560 ms 648 KB Output is correct
67 Correct 965 ms 656 KB Output is correct
68 Correct 3 ms 604 KB Output is correct
69 Execution timed out 1048 ms 604 KB Time limit exceeded
70 Halted 0 ms 0 KB -