답안 #1022388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1022388 2024-07-13T12:37:54 Z phoenix Bootfall (IZhO17_bootfall) C++17
44 / 100
1000 ms 4948 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 - (val >= MOD) * 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 << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4184 KB Output is correct
2 Correct 16 ms 4332 KB Output is correct
3 Correct 5 ms 4188 KB Output is correct
4 Correct 11 ms 4188 KB Output is correct
5 Correct 30 ms 4384 KB Output is correct
6 Correct 20 ms 4188 KB Output is correct
7 Correct 17 ms 4184 KB Output is correct
8 Correct 31 ms 4188 KB Output is correct
9 Correct 25 ms 4188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4184 KB Output is correct
2 Correct 16 ms 4332 KB Output is correct
3 Correct 5 ms 4188 KB Output is correct
4 Correct 11 ms 4188 KB Output is correct
5 Correct 30 ms 4384 KB Output is correct
6 Correct 20 ms 4188 KB Output is correct
7 Correct 17 ms 4184 KB Output is correct
8 Correct 31 ms 4188 KB Output is correct
9 Correct 25 ms 4188 KB Output is correct
10 Correct 75 ms 4184 KB Output is correct
11 Correct 73 ms 4184 KB Output is correct
12 Correct 74 ms 4184 KB Output is correct
13 Correct 63 ms 4188 KB Output is correct
14 Correct 86 ms 4188 KB Output is correct
15 Correct 70 ms 4188 KB Output is correct
16 Correct 74 ms 4188 KB Output is correct
17 Correct 46 ms 4188 KB Output is correct
18 Correct 59 ms 4360 KB Output is correct
19 Correct 65 ms 4188 KB Output is correct
20 Correct 73 ms 4188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4184 KB Output is correct
2 Correct 16 ms 4332 KB Output is correct
3 Correct 5 ms 4188 KB Output is correct
4 Correct 11 ms 4188 KB Output is correct
5 Correct 30 ms 4384 KB Output is correct
6 Correct 20 ms 4188 KB Output is correct
7 Correct 17 ms 4184 KB Output is correct
8 Correct 31 ms 4188 KB Output is correct
9 Correct 25 ms 4188 KB Output is correct
10 Correct 75 ms 4184 KB Output is correct
11 Correct 73 ms 4184 KB Output is correct
12 Correct 74 ms 4184 KB Output is correct
13 Correct 63 ms 4188 KB Output is correct
14 Correct 86 ms 4188 KB Output is correct
15 Correct 70 ms 4188 KB Output is correct
16 Correct 74 ms 4188 KB Output is correct
17 Correct 46 ms 4188 KB Output is correct
18 Correct 59 ms 4360 KB Output is correct
19 Correct 65 ms 4188 KB Output is correct
20 Correct 73 ms 4188 KB Output is correct
21 Correct 157 ms 4356 KB Output is correct
22 Correct 195 ms 4368 KB Output is correct
23 Correct 122 ms 4360 KB Output is correct
24 Correct 235 ms 4188 KB Output is correct
25 Correct 230 ms 4432 KB Output is correct
26 Correct 247 ms 4436 KB Output is correct
27 Correct 237 ms 4416 KB Output is correct
28 Correct 246 ms 4188 KB Output is correct
29 Correct 242 ms 4388 KB Output is correct
30 Correct 255 ms 4368 KB Output is correct
31 Correct 252 ms 4372 KB Output is correct
32 Correct 241 ms 4360 KB Output is correct
33 Correct 244 ms 4368 KB Output is correct
34 Correct 237 ms 4188 KB Output is correct
35 Correct 247 ms 4184 KB Output is correct
36 Correct 245 ms 4360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4184 KB Output is correct
2 Correct 16 ms 4332 KB Output is correct
3 Correct 5 ms 4188 KB Output is correct
4 Correct 11 ms 4188 KB Output is correct
5 Correct 30 ms 4384 KB Output is correct
6 Correct 20 ms 4188 KB Output is correct
7 Correct 17 ms 4184 KB Output is correct
8 Correct 31 ms 4188 KB Output is correct
9 Correct 25 ms 4188 KB Output is correct
10 Correct 75 ms 4184 KB Output is correct
11 Correct 73 ms 4184 KB Output is correct
12 Correct 74 ms 4184 KB Output is correct
13 Correct 63 ms 4188 KB Output is correct
14 Correct 86 ms 4188 KB Output is correct
15 Correct 70 ms 4188 KB Output is correct
16 Correct 74 ms 4188 KB Output is correct
17 Correct 46 ms 4188 KB Output is correct
18 Correct 59 ms 4360 KB Output is correct
19 Correct 65 ms 4188 KB Output is correct
20 Correct 73 ms 4188 KB Output is correct
21 Correct 157 ms 4356 KB Output is correct
22 Correct 195 ms 4368 KB Output is correct
23 Correct 122 ms 4360 KB Output is correct
24 Correct 235 ms 4188 KB Output is correct
25 Correct 230 ms 4432 KB Output is correct
26 Correct 247 ms 4436 KB Output is correct
27 Correct 237 ms 4416 KB Output is correct
28 Correct 246 ms 4188 KB Output is correct
29 Correct 242 ms 4388 KB Output is correct
30 Correct 255 ms 4368 KB Output is correct
31 Correct 252 ms 4372 KB Output is correct
32 Correct 241 ms 4360 KB Output is correct
33 Correct 244 ms 4368 KB Output is correct
34 Correct 237 ms 4188 KB Output is correct
35 Correct 247 ms 4184 KB Output is correct
36 Correct 245 ms 4360 KB Output is correct
37 Correct 560 ms 4432 KB Output is correct
38 Correct 546 ms 4432 KB Output is correct
39 Correct 599 ms 4600 KB Output is correct
40 Correct 839 ms 4476 KB Output is correct
41 Correct 692 ms 4644 KB Output is correct
42 Correct 749 ms 4612 KB Output is correct
43 Correct 845 ms 4948 KB Output is correct
44 Correct 845 ms 4948 KB Output is correct
45 Correct 872 ms 4868 KB Output is correct
46 Correct 736 ms 4480 KB Output is correct
47 Correct 772 ms 4488 KB Output is correct
48 Correct 837 ms 4692 KB Output is correct
49 Correct 750 ms 4600 KB Output is correct
50 Correct 755 ms 4688 KB Output is correct
51 Correct 233 ms 4188 KB Output is correct
52 Correct 981 ms 4944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4184 KB Output is correct
2 Correct 16 ms 4332 KB Output is correct
3 Correct 5 ms 4188 KB Output is correct
4 Correct 11 ms 4188 KB Output is correct
5 Correct 30 ms 4384 KB Output is correct
6 Correct 20 ms 4188 KB Output is correct
7 Correct 17 ms 4184 KB Output is correct
8 Correct 31 ms 4188 KB Output is correct
9 Correct 25 ms 4188 KB Output is correct
10 Correct 75 ms 4184 KB Output is correct
11 Correct 73 ms 4184 KB Output is correct
12 Correct 74 ms 4184 KB Output is correct
13 Correct 63 ms 4188 KB Output is correct
14 Correct 86 ms 4188 KB Output is correct
15 Correct 70 ms 4188 KB Output is correct
16 Correct 74 ms 4188 KB Output is correct
17 Correct 46 ms 4188 KB Output is correct
18 Correct 59 ms 4360 KB Output is correct
19 Correct 65 ms 4188 KB Output is correct
20 Correct 73 ms 4188 KB Output is correct
21 Correct 157 ms 4356 KB Output is correct
22 Correct 195 ms 4368 KB Output is correct
23 Correct 122 ms 4360 KB Output is correct
24 Correct 235 ms 4188 KB Output is correct
25 Correct 230 ms 4432 KB Output is correct
26 Correct 247 ms 4436 KB Output is correct
27 Correct 237 ms 4416 KB Output is correct
28 Correct 246 ms 4188 KB Output is correct
29 Correct 242 ms 4388 KB Output is correct
30 Correct 255 ms 4368 KB Output is correct
31 Correct 252 ms 4372 KB Output is correct
32 Correct 241 ms 4360 KB Output is correct
33 Correct 244 ms 4368 KB Output is correct
34 Correct 237 ms 4188 KB Output is correct
35 Correct 247 ms 4184 KB Output is correct
36 Correct 245 ms 4360 KB Output is correct
37 Correct 560 ms 4432 KB Output is correct
38 Correct 546 ms 4432 KB Output is correct
39 Correct 599 ms 4600 KB Output is correct
40 Correct 839 ms 4476 KB Output is correct
41 Correct 692 ms 4644 KB Output is correct
42 Correct 749 ms 4612 KB Output is correct
43 Correct 845 ms 4948 KB Output is correct
44 Correct 845 ms 4948 KB Output is correct
45 Correct 872 ms 4868 KB Output is correct
46 Correct 736 ms 4480 KB Output is correct
47 Correct 772 ms 4488 KB Output is correct
48 Correct 837 ms 4692 KB Output is correct
49 Correct 750 ms 4600 KB Output is correct
50 Correct 755 ms 4688 KB Output is correct
51 Correct 233 ms 4188 KB Output is correct
52 Correct 981 ms 4944 KB Output is correct
53 Execution timed out 1014 ms 4692 KB Time limit exceeded
54 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4184 KB Output is correct
2 Correct 16 ms 4332 KB Output is correct
3 Correct 5 ms 4188 KB Output is correct
4 Correct 11 ms 4188 KB Output is correct
5 Correct 30 ms 4384 KB Output is correct
6 Correct 20 ms 4188 KB Output is correct
7 Correct 17 ms 4184 KB Output is correct
8 Correct 31 ms 4188 KB Output is correct
9 Correct 25 ms 4188 KB Output is correct
10 Correct 75 ms 4184 KB Output is correct
11 Correct 73 ms 4184 KB Output is correct
12 Correct 74 ms 4184 KB Output is correct
13 Correct 63 ms 4188 KB Output is correct
14 Correct 86 ms 4188 KB Output is correct
15 Correct 70 ms 4188 KB Output is correct
16 Correct 74 ms 4188 KB Output is correct
17 Correct 46 ms 4188 KB Output is correct
18 Correct 59 ms 4360 KB Output is correct
19 Correct 65 ms 4188 KB Output is correct
20 Correct 73 ms 4188 KB Output is correct
21 Correct 157 ms 4356 KB Output is correct
22 Correct 195 ms 4368 KB Output is correct
23 Correct 122 ms 4360 KB Output is correct
24 Correct 235 ms 4188 KB Output is correct
25 Correct 230 ms 4432 KB Output is correct
26 Correct 247 ms 4436 KB Output is correct
27 Correct 237 ms 4416 KB Output is correct
28 Correct 246 ms 4188 KB Output is correct
29 Correct 242 ms 4388 KB Output is correct
30 Correct 255 ms 4368 KB Output is correct
31 Correct 252 ms 4372 KB Output is correct
32 Correct 241 ms 4360 KB Output is correct
33 Correct 244 ms 4368 KB Output is correct
34 Correct 237 ms 4188 KB Output is correct
35 Correct 247 ms 4184 KB Output is correct
36 Correct 245 ms 4360 KB Output is correct
37 Correct 560 ms 4432 KB Output is correct
38 Correct 546 ms 4432 KB Output is correct
39 Correct 599 ms 4600 KB Output is correct
40 Correct 839 ms 4476 KB Output is correct
41 Correct 692 ms 4644 KB Output is correct
42 Correct 749 ms 4612 KB Output is correct
43 Correct 845 ms 4948 KB Output is correct
44 Correct 845 ms 4948 KB Output is correct
45 Correct 872 ms 4868 KB Output is correct
46 Correct 736 ms 4480 KB Output is correct
47 Correct 772 ms 4488 KB Output is correct
48 Correct 837 ms 4692 KB Output is correct
49 Correct 750 ms 4600 KB Output is correct
50 Correct 755 ms 4688 KB Output is correct
51 Correct 233 ms 4188 KB Output is correct
52 Correct 981 ms 4944 KB Output is correct
53 Execution timed out 1014 ms 4692 KB Time limit exceeded
54 Halted 0 ms 0 KB -