답안 #1022385

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1022385 2024-07-13T12:35:19 Z phoenix Bootfall (IZhO17_bootfall) C++17
44 / 100
945 ms 3304 KB
#include <bits/stdc++.h>

using namespace std;

const int MOD1 = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int MOD3 = 998244353;
const int MOD4 = 999990011;

template<unsigned int MOD> 
struct mint {
    int v;
    mint() {}
    mint(long long val) : v(val % MOD + (val < 0) * MOD) {}
    mint<MOD>& operator += (mint<MOD> other) {
        *this = mint(v + other.v);
        return *this;
    }
    mint<MOD>& operator -= (mint<MOD> other) {
        *this = mint(v - other.v);
        return *this;
    }
};
const int N = 550;
const int A = 250000;

mint<MOD1> dp1[A]{1};
mint<MOD2> dp2[A]{1};
int sum = 0;

void add(int val) {
    sum += val;
    for (int i = A - 1; i >= val; i--) {
        dp1[i] += dp1[i - val];
        dp2[i] += dp2[i - val];
    }   
}

bool check(int sum) {
    assert(0 <= sum && sum < A);
    bool flag = true;
    flag &= (dp1[sum].v > 0);
    flag &= (dp2[sum].v > 0);
    return flag;
}

void del(int val) {
    sum -= val;
    for (int i = val; i < A; i++) {
        dp1[i] -= dp1[i - val];
        dp2[i] -= dp2[i - val];
    }
}

int n;
int a[N];

int cnt[A];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++) {
        add(a[i]);
    }
    if (sum & 1 || !check(sum / 2)) {
        cout << 0;
        return 0;
    }

    for (int i = 0; i < n; i++) {
        if (i) add(a[i - 1]);
        del(a[i]);
        for (int s = 0; s < A; s++) {
            if (check(s)) {
                cnt[abs(2 * s - sum)]++;
            }
        }
    }
    vector<int> res;
    for (int i = 0; i < A; i++) {
        if (cnt[i] == 2 * n) 
            res.push_back(i);
    }
    cout << (int)res.size() << '\n';
    for (int c : res) cout << c << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 2396 KB Output is correct
2 Correct 16 ms 2396 KB Output is correct
3 Correct 4 ms 2396 KB Output is correct
4 Correct 11 ms 2424 KB Output is correct
5 Correct 34 ms 2396 KB Output is correct
6 Correct 22 ms 2392 KB Output is correct
7 Correct 18 ms 2420 KB Output is correct
8 Correct 32 ms 2264 KB Output is correct
9 Correct 27 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 2396 KB Output is correct
2 Correct 16 ms 2396 KB Output is correct
3 Correct 4 ms 2396 KB Output is correct
4 Correct 11 ms 2424 KB Output is correct
5 Correct 34 ms 2396 KB Output is correct
6 Correct 22 ms 2392 KB Output is correct
7 Correct 18 ms 2420 KB Output is correct
8 Correct 32 ms 2264 KB Output is correct
9 Correct 27 ms 2396 KB Output is correct
10 Correct 89 ms 2392 KB Output is correct
11 Correct 85 ms 2404 KB Output is correct
12 Correct 81 ms 2396 KB Output is correct
13 Correct 73 ms 2400 KB Output is correct
14 Correct 77 ms 2404 KB Output is correct
15 Correct 79 ms 2396 KB Output is correct
16 Correct 85 ms 2396 KB Output is correct
17 Correct 53 ms 2396 KB Output is correct
18 Correct 65 ms 2392 KB Output is correct
19 Correct 71 ms 2392 KB Output is correct
20 Correct 84 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 2396 KB Output is correct
2 Correct 16 ms 2396 KB Output is correct
3 Correct 4 ms 2396 KB Output is correct
4 Correct 11 ms 2424 KB Output is correct
5 Correct 34 ms 2396 KB Output is correct
6 Correct 22 ms 2392 KB Output is correct
7 Correct 18 ms 2420 KB Output is correct
8 Correct 32 ms 2264 KB Output is correct
9 Correct 27 ms 2396 KB Output is correct
10 Correct 89 ms 2392 KB Output is correct
11 Correct 85 ms 2404 KB Output is correct
12 Correct 81 ms 2396 KB Output is correct
13 Correct 73 ms 2400 KB Output is correct
14 Correct 77 ms 2404 KB Output is correct
15 Correct 79 ms 2396 KB Output is correct
16 Correct 85 ms 2396 KB Output is correct
17 Correct 53 ms 2396 KB Output is correct
18 Correct 65 ms 2392 KB Output is correct
19 Correct 71 ms 2392 KB Output is correct
20 Correct 84 ms 2396 KB Output is correct
21 Correct 167 ms 2392 KB Output is correct
22 Correct 192 ms 2404 KB Output is correct
23 Correct 136 ms 2392 KB Output is correct
24 Correct 250 ms 2400 KB Output is correct
25 Correct 245 ms 2396 KB Output is correct
26 Correct 268 ms 2400 KB Output is correct
27 Correct 271 ms 2412 KB Output is correct
28 Correct 280 ms 2436 KB Output is correct
29 Correct 261 ms 2400 KB Output is correct
30 Correct 262 ms 2392 KB Output is correct
31 Correct 294 ms 2396 KB Output is correct
32 Correct 274 ms 2412 KB Output is correct
33 Correct 277 ms 2440 KB Output is correct
34 Correct 261 ms 2412 KB Output is correct
35 Correct 282 ms 2392 KB Output is correct
36 Correct 265 ms 2416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 2396 KB Output is correct
2 Correct 16 ms 2396 KB Output is correct
3 Correct 4 ms 2396 KB Output is correct
4 Correct 11 ms 2424 KB Output is correct
5 Correct 34 ms 2396 KB Output is correct
6 Correct 22 ms 2392 KB Output is correct
7 Correct 18 ms 2420 KB Output is correct
8 Correct 32 ms 2264 KB Output is correct
9 Correct 27 ms 2396 KB Output is correct
10 Correct 89 ms 2392 KB Output is correct
11 Correct 85 ms 2404 KB Output is correct
12 Correct 81 ms 2396 KB Output is correct
13 Correct 73 ms 2400 KB Output is correct
14 Correct 77 ms 2404 KB Output is correct
15 Correct 79 ms 2396 KB Output is correct
16 Correct 85 ms 2396 KB Output is correct
17 Correct 53 ms 2396 KB Output is correct
18 Correct 65 ms 2392 KB Output is correct
19 Correct 71 ms 2392 KB Output is correct
20 Correct 84 ms 2396 KB Output is correct
21 Correct 167 ms 2392 KB Output is correct
22 Correct 192 ms 2404 KB Output is correct
23 Correct 136 ms 2392 KB Output is correct
24 Correct 250 ms 2400 KB Output is correct
25 Correct 245 ms 2396 KB Output is correct
26 Correct 268 ms 2400 KB Output is correct
27 Correct 271 ms 2412 KB Output is correct
28 Correct 280 ms 2436 KB Output is correct
29 Correct 261 ms 2400 KB Output is correct
30 Correct 262 ms 2392 KB Output is correct
31 Correct 294 ms 2396 KB Output is correct
32 Correct 274 ms 2412 KB Output is correct
33 Correct 277 ms 2440 KB Output is correct
34 Correct 261 ms 2412 KB Output is correct
35 Correct 282 ms 2392 KB Output is correct
36 Correct 265 ms 2416 KB Output is correct
37 Correct 537 ms 2476 KB Output is correct
38 Correct 521 ms 2412 KB Output is correct
39 Correct 649 ms 2396 KB Output is correct
40 Correct 724 ms 2656 KB Output is correct
41 Correct 703 ms 2896 KB Output is correct
42 Correct 669 ms 2652 KB Output is correct
43 Correct 636 ms 2904 KB Output is correct
44 Correct 658 ms 2900 KB Output is correct
45 Correct 659 ms 2896 KB Output is correct
46 Correct 710 ms 2396 KB Output is correct
47 Correct 643 ms 2652 KB Output is correct
48 Correct 657 ms 2900 KB Output is correct
49 Correct 651 ms 2636 KB Output is correct
50 Correct 689 ms 2668 KB Output is correct
51 Correct 204 ms 2392 KB Output is correct
52 Correct 763 ms 2912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 2396 KB Output is correct
2 Correct 16 ms 2396 KB Output is correct
3 Correct 4 ms 2396 KB Output is correct
4 Correct 11 ms 2424 KB Output is correct
5 Correct 34 ms 2396 KB Output is correct
6 Correct 22 ms 2392 KB Output is correct
7 Correct 18 ms 2420 KB Output is correct
8 Correct 32 ms 2264 KB Output is correct
9 Correct 27 ms 2396 KB Output is correct
10 Correct 89 ms 2392 KB Output is correct
11 Correct 85 ms 2404 KB Output is correct
12 Correct 81 ms 2396 KB Output is correct
13 Correct 73 ms 2400 KB Output is correct
14 Correct 77 ms 2404 KB Output is correct
15 Correct 79 ms 2396 KB Output is correct
16 Correct 85 ms 2396 KB Output is correct
17 Correct 53 ms 2396 KB Output is correct
18 Correct 65 ms 2392 KB Output is correct
19 Correct 71 ms 2392 KB Output is correct
20 Correct 84 ms 2396 KB Output is correct
21 Correct 167 ms 2392 KB Output is correct
22 Correct 192 ms 2404 KB Output is correct
23 Correct 136 ms 2392 KB Output is correct
24 Correct 250 ms 2400 KB Output is correct
25 Correct 245 ms 2396 KB Output is correct
26 Correct 268 ms 2400 KB Output is correct
27 Correct 271 ms 2412 KB Output is correct
28 Correct 280 ms 2436 KB Output is correct
29 Correct 261 ms 2400 KB Output is correct
30 Correct 262 ms 2392 KB Output is correct
31 Correct 294 ms 2396 KB Output is correct
32 Correct 274 ms 2412 KB Output is correct
33 Correct 277 ms 2440 KB Output is correct
34 Correct 261 ms 2412 KB Output is correct
35 Correct 282 ms 2392 KB Output is correct
36 Correct 265 ms 2416 KB Output is correct
37 Correct 537 ms 2476 KB Output is correct
38 Correct 521 ms 2412 KB Output is correct
39 Correct 649 ms 2396 KB Output is correct
40 Correct 724 ms 2656 KB Output is correct
41 Correct 703 ms 2896 KB Output is correct
42 Correct 669 ms 2652 KB Output is correct
43 Correct 636 ms 2904 KB Output is correct
44 Correct 658 ms 2900 KB Output is correct
45 Correct 659 ms 2896 KB Output is correct
46 Correct 710 ms 2396 KB Output is correct
47 Correct 643 ms 2652 KB Output is correct
48 Correct 657 ms 2900 KB Output is correct
49 Correct 651 ms 2636 KB Output is correct
50 Correct 689 ms 2668 KB Output is correct
51 Correct 204 ms 2392 KB Output is correct
52 Correct 763 ms 2912 KB Output is correct
53 Correct 785 ms 2900 KB Output is correct
54 Correct 908 ms 2928 KB Output is correct
55 Correct 916 ms 3284 KB Output is correct
56 Correct 794 ms 2904 KB Output is correct
57 Correct 945 ms 3304 KB Output is correct
58 Correct 911 ms 2916 KB Output is correct
59 Incorrect 934 ms 3032 KB Output isn't correct
60 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 2396 KB Output is correct
2 Correct 16 ms 2396 KB Output is correct
3 Correct 4 ms 2396 KB Output is correct
4 Correct 11 ms 2424 KB Output is correct
5 Correct 34 ms 2396 KB Output is correct
6 Correct 22 ms 2392 KB Output is correct
7 Correct 18 ms 2420 KB Output is correct
8 Correct 32 ms 2264 KB Output is correct
9 Correct 27 ms 2396 KB Output is correct
10 Correct 89 ms 2392 KB Output is correct
11 Correct 85 ms 2404 KB Output is correct
12 Correct 81 ms 2396 KB Output is correct
13 Correct 73 ms 2400 KB Output is correct
14 Correct 77 ms 2404 KB Output is correct
15 Correct 79 ms 2396 KB Output is correct
16 Correct 85 ms 2396 KB Output is correct
17 Correct 53 ms 2396 KB Output is correct
18 Correct 65 ms 2392 KB Output is correct
19 Correct 71 ms 2392 KB Output is correct
20 Correct 84 ms 2396 KB Output is correct
21 Correct 167 ms 2392 KB Output is correct
22 Correct 192 ms 2404 KB Output is correct
23 Correct 136 ms 2392 KB Output is correct
24 Correct 250 ms 2400 KB Output is correct
25 Correct 245 ms 2396 KB Output is correct
26 Correct 268 ms 2400 KB Output is correct
27 Correct 271 ms 2412 KB Output is correct
28 Correct 280 ms 2436 KB Output is correct
29 Correct 261 ms 2400 KB Output is correct
30 Correct 262 ms 2392 KB Output is correct
31 Correct 294 ms 2396 KB Output is correct
32 Correct 274 ms 2412 KB Output is correct
33 Correct 277 ms 2440 KB Output is correct
34 Correct 261 ms 2412 KB Output is correct
35 Correct 282 ms 2392 KB Output is correct
36 Correct 265 ms 2416 KB Output is correct
37 Correct 537 ms 2476 KB Output is correct
38 Correct 521 ms 2412 KB Output is correct
39 Correct 649 ms 2396 KB Output is correct
40 Correct 724 ms 2656 KB Output is correct
41 Correct 703 ms 2896 KB Output is correct
42 Correct 669 ms 2652 KB Output is correct
43 Correct 636 ms 2904 KB Output is correct
44 Correct 658 ms 2900 KB Output is correct
45 Correct 659 ms 2896 KB Output is correct
46 Correct 710 ms 2396 KB Output is correct
47 Correct 643 ms 2652 KB Output is correct
48 Correct 657 ms 2900 KB Output is correct
49 Correct 651 ms 2636 KB Output is correct
50 Correct 689 ms 2668 KB Output is correct
51 Correct 204 ms 2392 KB Output is correct
52 Correct 763 ms 2912 KB Output is correct
53 Correct 785 ms 2900 KB Output is correct
54 Correct 908 ms 2928 KB Output is correct
55 Correct 916 ms 3284 KB Output is correct
56 Correct 794 ms 2904 KB Output is correct
57 Correct 945 ms 3304 KB Output is correct
58 Correct 911 ms 2916 KB Output is correct
59 Incorrect 934 ms 3032 KB Output isn't correct
60 Halted 0 ms 0 KB -