답안 #172964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
172964 2020-01-02T21:10:30 Z VEGAnn Bootfall (IZhO17_bootfall) C++14
44 / 100
251 ms 2676 KB
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define PB push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int N = 510;
const int N2 = N * N;
const int PW = 10;
const int VL = (1 << PW);
const int oo = 2e9;
const int K = 11;
const int md = 998244353;
vector<int> ans, nw;
int f[N2], a[N], n, pref;

int sum(int x, int y){ return (x + y) % md; }

void BAD(){
    cout << 0;
    exit(0);
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

    cin >> n;

    f[0] = 1;

    for (int i = 0; i < n; i++) {
        cin >> a[i];

        pref += a[i];

        for (int j = pref; j >= a[i]; j--)
            f[j] = sum(f[j], f[j - a[i]]);
    }

    if (pref & 1) BAD();
    if (f[pref >> 1] == 0) BAD();

    ans.clear();
    for (int i = 1; i < N2; i++)
        ans.PB(i);

    for (int i = 0; i < n; i++){
        for (int j = a[i]; j <= pref; j++)
            f[j] = sum(f[j], md - f[j - a[i]]);

        nw.clear();
        for (int x : ans){
            int sm = pref - a[i] + x;
            if (sm & 1) continue;
            if (f[sm >> 1] == 0) continue;
            nw.PB(x);
        }

        ans = nw;

        for (int j = pref; j >= a[i]; j--)
            f[j] = sum(f[j], f[j - a[i]]);
    }

    cout << sz(ans) << '\n';
    for (int x : ans)
        cout << x << " ";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1524 KB Output is correct
2 Correct 5 ms 1524 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 5 ms 1524 KB Output is correct
5 Correct 5 ms 1524 KB Output is correct
6 Correct 5 ms 1524 KB Output is correct
7 Correct 5 ms 1524 KB Output is correct
8 Correct 5 ms 1516 KB Output is correct
9 Correct 5 ms 1524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1524 KB Output is correct
2 Correct 5 ms 1524 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 5 ms 1524 KB Output is correct
5 Correct 5 ms 1524 KB Output is correct
6 Correct 5 ms 1524 KB Output is correct
7 Correct 5 ms 1524 KB Output is correct
8 Correct 5 ms 1516 KB Output is correct
9 Correct 5 ms 1524 KB Output is correct
10 Correct 5 ms 1524 KB Output is correct
11 Correct 5 ms 1524 KB Output is correct
12 Correct 5 ms 1524 KB Output is correct
13 Correct 5 ms 1520 KB Output is correct
14 Correct 5 ms 1524 KB Output is correct
15 Correct 5 ms 1524 KB Output is correct
16 Correct 5 ms 1520 KB Output is correct
17 Correct 5 ms 1524 KB Output is correct
18 Correct 5 ms 1524 KB Output is correct
19 Correct 5 ms 1524 KB Output is correct
20 Correct 5 ms 1524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1524 KB Output is correct
2 Correct 5 ms 1524 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 5 ms 1524 KB Output is correct
5 Correct 5 ms 1524 KB Output is correct
6 Correct 5 ms 1524 KB Output is correct
7 Correct 5 ms 1524 KB Output is correct
8 Correct 5 ms 1516 KB Output is correct
9 Correct 5 ms 1524 KB Output is correct
10 Correct 5 ms 1524 KB Output is correct
11 Correct 5 ms 1524 KB Output is correct
12 Correct 5 ms 1524 KB Output is correct
13 Correct 5 ms 1520 KB Output is correct
14 Correct 5 ms 1524 KB Output is correct
15 Correct 5 ms 1524 KB Output is correct
16 Correct 5 ms 1520 KB Output is correct
17 Correct 5 ms 1524 KB Output is correct
18 Correct 5 ms 1524 KB Output is correct
19 Correct 5 ms 1524 KB Output is correct
20 Correct 5 ms 1524 KB Output is correct
21 Correct 6 ms 1524 KB Output is correct
22 Correct 7 ms 1524 KB Output is correct
23 Correct 6 ms 1524 KB Output is correct
24 Correct 8 ms 1572 KB Output is correct
25 Correct 10 ms 1524 KB Output is correct
26 Correct 10 ms 1524 KB Output is correct
27 Correct 10 ms 1524 KB Output is correct
28 Correct 10 ms 1524 KB Output is correct
29 Correct 10 ms 1520 KB Output is correct
30 Correct 7 ms 1524 KB Output is correct
31 Correct 10 ms 1524 KB Output is correct
32 Correct 8 ms 1520 KB Output is correct
33 Correct 10 ms 1524 KB Output is correct
34 Correct 10 ms 1524 KB Output is correct
35 Correct 9 ms 1524 KB Output is correct
36 Correct 8 ms 1524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1524 KB Output is correct
2 Correct 5 ms 1524 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 5 ms 1524 KB Output is correct
5 Correct 5 ms 1524 KB Output is correct
6 Correct 5 ms 1524 KB Output is correct
7 Correct 5 ms 1524 KB Output is correct
8 Correct 5 ms 1516 KB Output is correct
9 Correct 5 ms 1524 KB Output is correct
10 Correct 5 ms 1524 KB Output is correct
11 Correct 5 ms 1524 KB Output is correct
12 Correct 5 ms 1524 KB Output is correct
13 Correct 5 ms 1520 KB Output is correct
14 Correct 5 ms 1524 KB Output is correct
15 Correct 5 ms 1524 KB Output is correct
16 Correct 5 ms 1520 KB Output is correct
17 Correct 5 ms 1524 KB Output is correct
18 Correct 5 ms 1524 KB Output is correct
19 Correct 5 ms 1524 KB Output is correct
20 Correct 5 ms 1524 KB Output is correct
21 Correct 6 ms 1524 KB Output is correct
22 Correct 7 ms 1524 KB Output is correct
23 Correct 6 ms 1524 KB Output is correct
24 Correct 8 ms 1572 KB Output is correct
25 Correct 10 ms 1524 KB Output is correct
26 Correct 10 ms 1524 KB Output is correct
27 Correct 10 ms 1524 KB Output is correct
28 Correct 10 ms 1524 KB Output is correct
29 Correct 10 ms 1520 KB Output is correct
30 Correct 7 ms 1524 KB Output is correct
31 Correct 10 ms 1524 KB Output is correct
32 Correct 8 ms 1520 KB Output is correct
33 Correct 10 ms 1524 KB Output is correct
34 Correct 10 ms 1524 KB Output is correct
35 Correct 9 ms 1524 KB Output is correct
36 Correct 8 ms 1524 KB Output is correct
37 Correct 29 ms 1624 KB Output is correct
38 Correct 29 ms 1648 KB Output is correct
39 Correct 78 ms 1780 KB Output is correct
40 Correct 59 ms 1652 KB Output is correct
41 Correct 98 ms 1780 KB Output is correct
42 Correct 51 ms 1772 KB Output is correct
43 Correct 87 ms 2032 KB Output is correct
44 Correct 89 ms 1916 KB Output is correct
45 Correct 91 ms 2028 KB Output is correct
46 Correct 45 ms 1652 KB Output is correct
47 Correct 55 ms 1712 KB Output is correct
48 Correct 91 ms 1904 KB Output is correct
49 Correct 81 ms 1780 KB Output is correct
50 Correct 55 ms 1744 KB Output is correct
51 Correct 9 ms 504 KB Output is correct
52 Correct 117 ms 2128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1524 KB Output is correct
2 Correct 5 ms 1524 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 5 ms 1524 KB Output is correct
5 Correct 5 ms 1524 KB Output is correct
6 Correct 5 ms 1524 KB Output is correct
7 Correct 5 ms 1524 KB Output is correct
8 Correct 5 ms 1516 KB Output is correct
9 Correct 5 ms 1524 KB Output is correct
10 Correct 5 ms 1524 KB Output is correct
11 Correct 5 ms 1524 KB Output is correct
12 Correct 5 ms 1524 KB Output is correct
13 Correct 5 ms 1520 KB Output is correct
14 Correct 5 ms 1524 KB Output is correct
15 Correct 5 ms 1524 KB Output is correct
16 Correct 5 ms 1520 KB Output is correct
17 Correct 5 ms 1524 KB Output is correct
18 Correct 5 ms 1524 KB Output is correct
19 Correct 5 ms 1524 KB Output is correct
20 Correct 5 ms 1524 KB Output is correct
21 Correct 6 ms 1524 KB Output is correct
22 Correct 7 ms 1524 KB Output is correct
23 Correct 6 ms 1524 KB Output is correct
24 Correct 8 ms 1572 KB Output is correct
25 Correct 10 ms 1524 KB Output is correct
26 Correct 10 ms 1524 KB Output is correct
27 Correct 10 ms 1524 KB Output is correct
28 Correct 10 ms 1524 KB Output is correct
29 Correct 10 ms 1520 KB Output is correct
30 Correct 7 ms 1524 KB Output is correct
31 Correct 10 ms 1524 KB Output is correct
32 Correct 8 ms 1520 KB Output is correct
33 Correct 10 ms 1524 KB Output is correct
34 Correct 10 ms 1524 KB Output is correct
35 Correct 9 ms 1524 KB Output is correct
36 Correct 8 ms 1524 KB Output is correct
37 Correct 29 ms 1624 KB Output is correct
38 Correct 29 ms 1648 KB Output is correct
39 Correct 78 ms 1780 KB Output is correct
40 Correct 59 ms 1652 KB Output is correct
41 Correct 98 ms 1780 KB Output is correct
42 Correct 51 ms 1772 KB Output is correct
43 Correct 87 ms 2032 KB Output is correct
44 Correct 89 ms 1916 KB Output is correct
45 Correct 91 ms 2028 KB Output is correct
46 Correct 45 ms 1652 KB Output is correct
47 Correct 55 ms 1712 KB Output is correct
48 Correct 91 ms 1904 KB Output is correct
49 Correct 81 ms 1780 KB Output is correct
50 Correct 55 ms 1744 KB Output is correct
51 Correct 9 ms 504 KB Output is correct
52 Correct 117 ms 2128 KB Output is correct
53 Correct 88 ms 1904 KB Output is correct
54 Correct 123 ms 2028 KB Output is correct
55 Correct 237 ms 2676 KB Output is correct
56 Correct 109 ms 2032 KB Output is correct
57 Correct 251 ms 2648 KB Output is correct
58 Incorrect 136 ms 2160 KB Output isn't correct
59 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1524 KB Output is correct
2 Correct 5 ms 1524 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 5 ms 1524 KB Output is correct
5 Correct 5 ms 1524 KB Output is correct
6 Correct 5 ms 1524 KB Output is correct
7 Correct 5 ms 1524 KB Output is correct
8 Correct 5 ms 1516 KB Output is correct
9 Correct 5 ms 1524 KB Output is correct
10 Correct 5 ms 1524 KB Output is correct
11 Correct 5 ms 1524 KB Output is correct
12 Correct 5 ms 1524 KB Output is correct
13 Correct 5 ms 1520 KB Output is correct
14 Correct 5 ms 1524 KB Output is correct
15 Correct 5 ms 1524 KB Output is correct
16 Correct 5 ms 1520 KB Output is correct
17 Correct 5 ms 1524 KB Output is correct
18 Correct 5 ms 1524 KB Output is correct
19 Correct 5 ms 1524 KB Output is correct
20 Correct 5 ms 1524 KB Output is correct
21 Correct 6 ms 1524 KB Output is correct
22 Correct 7 ms 1524 KB Output is correct
23 Correct 6 ms 1524 KB Output is correct
24 Correct 8 ms 1572 KB Output is correct
25 Correct 10 ms 1524 KB Output is correct
26 Correct 10 ms 1524 KB Output is correct
27 Correct 10 ms 1524 KB Output is correct
28 Correct 10 ms 1524 KB Output is correct
29 Correct 10 ms 1520 KB Output is correct
30 Correct 7 ms 1524 KB Output is correct
31 Correct 10 ms 1524 KB Output is correct
32 Correct 8 ms 1520 KB Output is correct
33 Correct 10 ms 1524 KB Output is correct
34 Correct 10 ms 1524 KB Output is correct
35 Correct 9 ms 1524 KB Output is correct
36 Correct 8 ms 1524 KB Output is correct
37 Correct 29 ms 1624 KB Output is correct
38 Correct 29 ms 1648 KB Output is correct
39 Correct 78 ms 1780 KB Output is correct
40 Correct 59 ms 1652 KB Output is correct
41 Correct 98 ms 1780 KB Output is correct
42 Correct 51 ms 1772 KB Output is correct
43 Correct 87 ms 2032 KB Output is correct
44 Correct 89 ms 1916 KB Output is correct
45 Correct 91 ms 2028 KB Output is correct
46 Correct 45 ms 1652 KB Output is correct
47 Correct 55 ms 1712 KB Output is correct
48 Correct 91 ms 1904 KB Output is correct
49 Correct 81 ms 1780 KB Output is correct
50 Correct 55 ms 1744 KB Output is correct
51 Correct 9 ms 504 KB Output is correct
52 Correct 117 ms 2128 KB Output is correct
53 Correct 88 ms 1904 KB Output is correct
54 Correct 123 ms 2028 KB Output is correct
55 Correct 237 ms 2676 KB Output is correct
56 Correct 109 ms 2032 KB Output is correct
57 Correct 251 ms 2648 KB Output is correct
58 Incorrect 136 ms 2160 KB Output isn't correct
59 Halted 0 ms 0 KB -