Submission #1022384

# Submission time Handle Problem Language Result Execution time Memory
1022384 2024-07-13T12:34:27 Z phoenix Bootfall (IZhO17_bootfall) C++17
28 / 100
1000 ms 4660 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};
mint<MOD3> dp3[A]{1};
mint<MOD4> dp4[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];
        dp3[i] += dp3[i - val];
        dp4[i] += dp4[i - val];
    }   
}

bool check(int sum) {
    assert(0 <= sum && sum < A);
    bool flag = true;
    flag &= (dp1[sum].v > 0);
    flag &= (dp2[sum].v > 0);
    flag &= (dp3[sum].v > 0);
    flag &= (dp4[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];
        dp3[i] -= dp3[i - val];
        dp4[i] -= dp4[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 << ' ';
}
# Verdict Execution time Memory Grader output
1 Correct 22 ms 4384 KB Output is correct
2 Correct 34 ms 4444 KB Output is correct
3 Correct 7 ms 4212 KB Output is correct
4 Correct 21 ms 4184 KB Output is correct
5 Correct 61 ms 4188 KB Output is correct
6 Correct 41 ms 4184 KB Output is correct
7 Correct 32 ms 4184 KB Output is correct
8 Correct 62 ms 4188 KB Output is correct
9 Correct 52 ms 4188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 4384 KB Output is correct
2 Correct 34 ms 4444 KB Output is correct
3 Correct 7 ms 4212 KB Output is correct
4 Correct 21 ms 4184 KB Output is correct
5 Correct 61 ms 4188 KB Output is correct
6 Correct 41 ms 4184 KB Output is correct
7 Correct 32 ms 4184 KB Output is correct
8 Correct 62 ms 4188 KB Output is correct
9 Correct 52 ms 4188 KB Output is correct
10 Correct 150 ms 4188 KB Output is correct
11 Correct 146 ms 4188 KB Output is correct
12 Correct 151 ms 4184 KB Output is correct
13 Correct 132 ms 4188 KB Output is correct
14 Correct 139 ms 4188 KB Output is correct
15 Correct 150 ms 4184 KB Output is correct
16 Correct 150 ms 4184 KB Output is correct
17 Correct 90 ms 4184 KB Output is correct
18 Correct 119 ms 4280 KB Output is correct
19 Correct 129 ms 4184 KB Output is correct
20 Correct 154 ms 4436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 4384 KB Output is correct
2 Correct 34 ms 4444 KB Output is correct
3 Correct 7 ms 4212 KB Output is correct
4 Correct 21 ms 4184 KB Output is correct
5 Correct 61 ms 4188 KB Output is correct
6 Correct 41 ms 4184 KB Output is correct
7 Correct 32 ms 4184 KB Output is correct
8 Correct 62 ms 4188 KB Output is correct
9 Correct 52 ms 4188 KB Output is correct
10 Correct 150 ms 4188 KB Output is correct
11 Correct 146 ms 4188 KB Output is correct
12 Correct 151 ms 4184 KB Output is correct
13 Correct 132 ms 4188 KB Output is correct
14 Correct 139 ms 4188 KB Output is correct
15 Correct 150 ms 4184 KB Output is correct
16 Correct 150 ms 4184 KB Output is correct
17 Correct 90 ms 4184 KB Output is correct
18 Correct 119 ms 4280 KB Output is correct
19 Correct 129 ms 4184 KB Output is correct
20 Correct 154 ms 4436 KB Output is correct
21 Correct 316 ms 4352 KB Output is correct
22 Correct 365 ms 4188 KB Output is correct
23 Correct 260 ms 4184 KB Output is correct
24 Correct 460 ms 4368 KB Output is correct
25 Correct 464 ms 4368 KB Output is correct
26 Correct 497 ms 4660 KB Output is correct
27 Correct 492 ms 4352 KB Output is correct
28 Correct 490 ms 4436 KB Output is correct
29 Correct 492 ms 4188 KB Output is correct
30 Correct 501 ms 4356 KB Output is correct
31 Correct 500 ms 4388 KB Output is correct
32 Correct 518 ms 4376 KB Output is correct
33 Correct 488 ms 4188 KB Output is correct
34 Correct 497 ms 4396 KB Output is correct
35 Correct 497 ms 4360 KB Output is correct
36 Correct 498 ms 4448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 4384 KB Output is correct
2 Correct 34 ms 4444 KB Output is correct
3 Correct 7 ms 4212 KB Output is correct
4 Correct 21 ms 4184 KB Output is correct
5 Correct 61 ms 4188 KB Output is correct
6 Correct 41 ms 4184 KB Output is correct
7 Correct 32 ms 4184 KB Output is correct
8 Correct 62 ms 4188 KB Output is correct
9 Correct 52 ms 4188 KB Output is correct
10 Correct 150 ms 4188 KB Output is correct
11 Correct 146 ms 4188 KB Output is correct
12 Correct 151 ms 4184 KB Output is correct
13 Correct 132 ms 4188 KB Output is correct
14 Correct 139 ms 4188 KB Output is correct
15 Correct 150 ms 4184 KB Output is correct
16 Correct 150 ms 4184 KB Output is correct
17 Correct 90 ms 4184 KB Output is correct
18 Correct 119 ms 4280 KB Output is correct
19 Correct 129 ms 4184 KB Output is correct
20 Correct 154 ms 4436 KB Output is correct
21 Correct 316 ms 4352 KB Output is correct
22 Correct 365 ms 4188 KB Output is correct
23 Correct 260 ms 4184 KB Output is correct
24 Correct 460 ms 4368 KB Output is correct
25 Correct 464 ms 4368 KB Output is correct
26 Correct 497 ms 4660 KB Output is correct
27 Correct 492 ms 4352 KB Output is correct
28 Correct 490 ms 4436 KB Output is correct
29 Correct 492 ms 4188 KB Output is correct
30 Correct 501 ms 4356 KB Output is correct
31 Correct 500 ms 4388 KB Output is correct
32 Correct 518 ms 4376 KB Output is correct
33 Correct 488 ms 4188 KB Output is correct
34 Correct 497 ms 4396 KB Output is correct
35 Correct 497 ms 4360 KB Output is correct
36 Correct 498 ms 4448 KB Output is correct
37 Correct 991 ms 4428 KB Output is correct
38 Execution timed out 1008 ms 4356 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 4384 KB Output is correct
2 Correct 34 ms 4444 KB Output is correct
3 Correct 7 ms 4212 KB Output is correct
4 Correct 21 ms 4184 KB Output is correct
5 Correct 61 ms 4188 KB Output is correct
6 Correct 41 ms 4184 KB Output is correct
7 Correct 32 ms 4184 KB Output is correct
8 Correct 62 ms 4188 KB Output is correct
9 Correct 52 ms 4188 KB Output is correct
10 Correct 150 ms 4188 KB Output is correct
11 Correct 146 ms 4188 KB Output is correct
12 Correct 151 ms 4184 KB Output is correct
13 Correct 132 ms 4188 KB Output is correct
14 Correct 139 ms 4188 KB Output is correct
15 Correct 150 ms 4184 KB Output is correct
16 Correct 150 ms 4184 KB Output is correct
17 Correct 90 ms 4184 KB Output is correct
18 Correct 119 ms 4280 KB Output is correct
19 Correct 129 ms 4184 KB Output is correct
20 Correct 154 ms 4436 KB Output is correct
21 Correct 316 ms 4352 KB Output is correct
22 Correct 365 ms 4188 KB Output is correct
23 Correct 260 ms 4184 KB Output is correct
24 Correct 460 ms 4368 KB Output is correct
25 Correct 464 ms 4368 KB Output is correct
26 Correct 497 ms 4660 KB Output is correct
27 Correct 492 ms 4352 KB Output is correct
28 Correct 490 ms 4436 KB Output is correct
29 Correct 492 ms 4188 KB Output is correct
30 Correct 501 ms 4356 KB Output is correct
31 Correct 500 ms 4388 KB Output is correct
32 Correct 518 ms 4376 KB Output is correct
33 Correct 488 ms 4188 KB Output is correct
34 Correct 497 ms 4396 KB Output is correct
35 Correct 497 ms 4360 KB Output is correct
36 Correct 498 ms 4448 KB Output is correct
37 Correct 991 ms 4428 KB Output is correct
38 Execution timed out 1008 ms 4356 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 4384 KB Output is correct
2 Correct 34 ms 4444 KB Output is correct
3 Correct 7 ms 4212 KB Output is correct
4 Correct 21 ms 4184 KB Output is correct
5 Correct 61 ms 4188 KB Output is correct
6 Correct 41 ms 4184 KB Output is correct
7 Correct 32 ms 4184 KB Output is correct
8 Correct 62 ms 4188 KB Output is correct
9 Correct 52 ms 4188 KB Output is correct
10 Correct 150 ms 4188 KB Output is correct
11 Correct 146 ms 4188 KB Output is correct
12 Correct 151 ms 4184 KB Output is correct
13 Correct 132 ms 4188 KB Output is correct
14 Correct 139 ms 4188 KB Output is correct
15 Correct 150 ms 4184 KB Output is correct
16 Correct 150 ms 4184 KB Output is correct
17 Correct 90 ms 4184 KB Output is correct
18 Correct 119 ms 4280 KB Output is correct
19 Correct 129 ms 4184 KB Output is correct
20 Correct 154 ms 4436 KB Output is correct
21 Correct 316 ms 4352 KB Output is correct
22 Correct 365 ms 4188 KB Output is correct
23 Correct 260 ms 4184 KB Output is correct
24 Correct 460 ms 4368 KB Output is correct
25 Correct 464 ms 4368 KB Output is correct
26 Correct 497 ms 4660 KB Output is correct
27 Correct 492 ms 4352 KB Output is correct
28 Correct 490 ms 4436 KB Output is correct
29 Correct 492 ms 4188 KB Output is correct
30 Correct 501 ms 4356 KB Output is correct
31 Correct 500 ms 4388 KB Output is correct
32 Correct 518 ms 4376 KB Output is correct
33 Correct 488 ms 4188 KB Output is correct
34 Correct 497 ms 4396 KB Output is correct
35 Correct 497 ms 4360 KB Output is correct
36 Correct 498 ms 4448 KB Output is correct
37 Correct 991 ms 4428 KB Output is correct
38 Execution timed out 1008 ms 4356 KB Time limit exceeded
39 Halted 0 ms 0 KB -