답안 #947602

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
947602 2024-03-16T14:49:48 Z Pring Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 908 KB
#include <bits/stdc++.h>
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 604 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 3 ms 604 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 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 3 ms 604 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 8 ms 676 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 6 ms 604 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 7 ms 856 KB Output is correct
17 Correct 3 ms 852 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 6 ms 604 KB Output is correct
20 Correct 7 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 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 3 ms 604 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 8 ms 676 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 6 ms 604 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 7 ms 856 KB Output is correct
17 Correct 3 ms 852 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 6 ms 604 KB Output is correct
20 Correct 7 ms 604 KB Output is correct
21 Correct 30 ms 604 KB Output is correct
22 Correct 44 ms 668 KB Output is correct
23 Correct 19 ms 604 KB Output is correct
24 Correct 65 ms 652 KB Output is correct
25 Correct 66 ms 760 KB Output is correct
26 Correct 73 ms 648 KB Output is correct
27 Correct 75 ms 604 KB Output is correct
28 Correct 74 ms 604 KB Output is correct
29 Correct 74 ms 652 KB Output is correct
30 Correct 74 ms 652 KB Output is correct
31 Correct 73 ms 648 KB Output is correct
32 Correct 73 ms 604 KB Output is correct
33 Correct 87 ms 604 KB Output is correct
34 Correct 85 ms 852 KB Output is correct
35 Correct 73 ms 648 KB Output is correct
36 Correct 74 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 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 3 ms 604 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 8 ms 676 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 6 ms 604 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 7 ms 856 KB Output is correct
17 Correct 3 ms 852 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 6 ms 604 KB Output is correct
20 Correct 7 ms 604 KB Output is correct
21 Correct 30 ms 604 KB Output is correct
22 Correct 44 ms 668 KB Output is correct
23 Correct 19 ms 604 KB Output is correct
24 Correct 65 ms 652 KB Output is correct
25 Correct 66 ms 760 KB Output is correct
26 Correct 73 ms 648 KB Output is correct
27 Correct 75 ms 604 KB Output is correct
28 Correct 74 ms 604 KB Output is correct
29 Correct 74 ms 652 KB Output is correct
30 Correct 74 ms 652 KB Output is correct
31 Correct 73 ms 648 KB Output is correct
32 Correct 73 ms 604 KB Output is correct
33 Correct 87 ms 604 KB Output is correct
34 Correct 85 ms 852 KB Output is correct
35 Correct 73 ms 648 KB Output is correct
36 Correct 74 ms 604 KB Output is correct
37 Correct 308 ms 648 KB Output is correct
38 Correct 296 ms 604 KB Output is correct
39 Correct 468 ms 652 KB Output is correct
40 Correct 534 ms 652 KB Output is correct
41 Correct 548 ms 664 KB Output is correct
42 Correct 480 ms 664 KB Output is correct
43 Correct 455 ms 648 KB Output is correct
44 Correct 516 ms 848 KB Output is correct
45 Correct 510 ms 864 KB Output is correct
46 Correct 538 ms 604 KB Output is correct
47 Correct 468 ms 868 KB Output is correct
48 Correct 486 ms 664 KB Output is correct
49 Correct 469 ms 604 KB Output is correct
50 Correct 463 ms 856 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 564 ms 652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 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 3 ms 604 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 8 ms 676 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 6 ms 604 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 7 ms 856 KB Output is correct
17 Correct 3 ms 852 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 6 ms 604 KB Output is correct
20 Correct 7 ms 604 KB Output is correct
21 Correct 30 ms 604 KB Output is correct
22 Correct 44 ms 668 KB Output is correct
23 Correct 19 ms 604 KB Output is correct
24 Correct 65 ms 652 KB Output is correct
25 Correct 66 ms 760 KB Output is correct
26 Correct 73 ms 648 KB Output is correct
27 Correct 75 ms 604 KB Output is correct
28 Correct 74 ms 604 KB Output is correct
29 Correct 74 ms 652 KB Output is correct
30 Correct 74 ms 652 KB Output is correct
31 Correct 73 ms 648 KB Output is correct
32 Correct 73 ms 604 KB Output is correct
33 Correct 87 ms 604 KB Output is correct
34 Correct 85 ms 852 KB Output is correct
35 Correct 73 ms 648 KB Output is correct
36 Correct 74 ms 604 KB Output is correct
37 Correct 308 ms 648 KB Output is correct
38 Correct 296 ms 604 KB Output is correct
39 Correct 468 ms 652 KB Output is correct
40 Correct 534 ms 652 KB Output is correct
41 Correct 548 ms 664 KB Output is correct
42 Correct 480 ms 664 KB Output is correct
43 Correct 455 ms 648 KB Output is correct
44 Correct 516 ms 848 KB Output is correct
45 Correct 510 ms 864 KB Output is correct
46 Correct 538 ms 604 KB Output is correct
47 Correct 468 ms 868 KB Output is correct
48 Correct 486 ms 664 KB Output is correct
49 Correct 469 ms 604 KB Output is correct
50 Correct 463 ms 856 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 564 ms 652 KB Output is correct
53 Correct 682 ms 604 KB Output is correct
54 Correct 958 ms 852 KB Output is correct
55 Correct 951 ms 904 KB Output is correct
56 Correct 709 ms 852 KB Output is correct
57 Correct 966 ms 904 KB Output is correct
58 Correct 928 ms 652 KB Output is correct
59 Correct 940 ms 652 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 949 ms 648 KB Output is correct
62 Correct 821 ms 908 KB Output is correct
63 Correct 789 ms 908 KB Output is correct
64 Correct 766 ms 908 KB Output is correct
65 Correct 739 ms 604 KB Output is correct
66 Correct 731 ms 664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 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 3 ms 604 KB Output is correct
6 Correct 1 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 2 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 7 ms 604 KB Output is correct
11 Correct 7 ms 604 KB Output is correct
12 Correct 8 ms 676 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 6 ms 604 KB Output is correct
15 Correct 6 ms 604 KB Output is correct
16 Correct 7 ms 856 KB Output is correct
17 Correct 3 ms 852 KB Output is correct
18 Correct 5 ms 604 KB Output is correct
19 Correct 6 ms 604 KB Output is correct
20 Correct 7 ms 604 KB Output is correct
21 Correct 30 ms 604 KB Output is correct
22 Correct 44 ms 668 KB Output is correct
23 Correct 19 ms 604 KB Output is correct
24 Correct 65 ms 652 KB Output is correct
25 Correct 66 ms 760 KB Output is correct
26 Correct 73 ms 648 KB Output is correct
27 Correct 75 ms 604 KB Output is correct
28 Correct 74 ms 604 KB Output is correct
29 Correct 74 ms 652 KB Output is correct
30 Correct 74 ms 652 KB Output is correct
31 Correct 73 ms 648 KB Output is correct
32 Correct 73 ms 604 KB Output is correct
33 Correct 87 ms 604 KB Output is correct
34 Correct 85 ms 852 KB Output is correct
35 Correct 73 ms 648 KB Output is correct
36 Correct 74 ms 604 KB Output is correct
37 Correct 308 ms 648 KB Output is correct
38 Correct 296 ms 604 KB Output is correct
39 Correct 468 ms 652 KB Output is correct
40 Correct 534 ms 652 KB Output is correct
41 Correct 548 ms 664 KB Output is correct
42 Correct 480 ms 664 KB Output is correct
43 Correct 455 ms 648 KB Output is correct
44 Correct 516 ms 848 KB Output is correct
45 Correct 510 ms 864 KB Output is correct
46 Correct 538 ms 604 KB Output is correct
47 Correct 468 ms 868 KB Output is correct
48 Correct 486 ms 664 KB Output is correct
49 Correct 469 ms 604 KB Output is correct
50 Correct 463 ms 856 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 564 ms 652 KB Output is correct
53 Correct 682 ms 604 KB Output is correct
54 Correct 958 ms 852 KB Output is correct
55 Correct 951 ms 904 KB Output is correct
56 Correct 709 ms 852 KB Output is correct
57 Correct 966 ms 904 KB Output is correct
58 Correct 928 ms 652 KB Output is correct
59 Correct 940 ms 652 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 949 ms 648 KB Output is correct
62 Correct 821 ms 908 KB Output is correct
63 Correct 789 ms 908 KB Output is correct
64 Correct 766 ms 908 KB Output is correct
65 Correct 739 ms 604 KB Output is correct
66 Correct 731 ms 664 KB Output is correct
67 Execution timed out 1058 ms 604 KB Time limit exceeded
68 Halted 0 ms 0 KB -