답안 #173463

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173463 2020-01-04T08:12:55 Z srvlt Bootfall (IZhO17_bootfall) C++14
28 / 100
154 ms 760 KB
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree <pair <int, int>, null_type, less <pair <int, int> >, rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define size(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define low_b lower_bound

#define endl "\n"
//#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 102, M = 10001;
int n, a[N], total;
bitset <M> p[N], s[N], res, ans, tmp;

void dbg(bitset <M> & b) {
    for (int i = 0; i < M; i++) {
        cout << b[i];
    }
    cout << endl;
}

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n;
    p[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        total += a[i];
        p[i] = p[i - 1];
        p[i] |= (p[i] << a[i]);
    }
    if ((total & 1) || !p[n][total >> 1]) {
        cout << 0;
        return;
    }
    s[n + 1][0] = 1;
    for (int i = n; i >= 1; i--) {
        s[i] = s[i + 1];
        s[i] |= (s[i] << a[i]);
    }
    int w;
    ans.set();
    for (int i = 1; i <= n; i++) {
        tmp = s[i + 1];
        for (int j = 1; j < M; j++) {
            if (p[i - 1][j]) {
                tmp |= (s[i + 1] << j);
            }
        }
        res.reset();
        w = total - a[i];
        for (int j = (w & 1); j <= w; j += 2) {
            if (tmp[w + j >> 1] || tmp[w - j >> 1]) {
                res[j] = 1;
            }
        }
        ans &= res;
    }
    cout << ans.count() << endl;
    for (int i = 0; i < M; i++) {
        if (ans[i]) {
            cout << i << " ";
        }
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}

Compilation message

bootfall.cpp: In function 'void solve(int)':
bootfall.cpp:80:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
             if (tmp[w + j >> 1] || tmp[w - j >> 1]) {
                     ~~^~~
bootfall.cpp:80:42: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
             if (tmp[w + j >> 1] || tmp[w - j >> 1]) {
                                        ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 9 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 9 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 4 ms 380 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 4 ms 380 KB Output is correct
19 Correct 4 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 9 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 4 ms 380 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 4 ms 380 KB Output is correct
19 Correct 4 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 47 ms 504 KB Output is correct
22 Correct 63 ms 504 KB Output is correct
23 Correct 28 ms 632 KB Output is correct
24 Correct 93 ms 632 KB Output is correct
25 Correct 100 ms 616 KB Output is correct
26 Correct 118 ms 632 KB Output is correct
27 Correct 81 ms 632 KB Output is correct
28 Correct 64 ms 632 KB Output is correct
29 Correct 81 ms 732 KB Output is correct
30 Correct 117 ms 632 KB Output is correct
31 Correct 154 ms 632 KB Output is correct
32 Correct 109 ms 668 KB Output is correct
33 Correct 8 ms 712 KB Output is correct
34 Correct 8 ms 632 KB Output is correct
35 Correct 61 ms 640 KB Output is correct
36 Correct 103 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 9 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 4 ms 380 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 4 ms 380 KB Output is correct
19 Correct 4 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 47 ms 504 KB Output is correct
22 Correct 63 ms 504 KB Output is correct
23 Correct 28 ms 632 KB Output is correct
24 Correct 93 ms 632 KB Output is correct
25 Correct 100 ms 616 KB Output is correct
26 Correct 118 ms 632 KB Output is correct
27 Correct 81 ms 632 KB Output is correct
28 Correct 64 ms 632 KB Output is correct
29 Correct 81 ms 732 KB Output is correct
30 Correct 117 ms 632 KB Output is correct
31 Correct 154 ms 632 KB Output is correct
32 Correct 109 ms 668 KB Output is correct
33 Correct 8 ms 712 KB Output is correct
34 Correct 8 ms 632 KB Output is correct
35 Correct 61 ms 640 KB Output is correct
36 Correct 103 ms 632 KB Output is correct
37 Runtime error 4 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 9 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 4 ms 380 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 4 ms 380 KB Output is correct
19 Correct 4 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 47 ms 504 KB Output is correct
22 Correct 63 ms 504 KB Output is correct
23 Correct 28 ms 632 KB Output is correct
24 Correct 93 ms 632 KB Output is correct
25 Correct 100 ms 616 KB Output is correct
26 Correct 118 ms 632 KB Output is correct
27 Correct 81 ms 632 KB Output is correct
28 Correct 64 ms 632 KB Output is correct
29 Correct 81 ms 732 KB Output is correct
30 Correct 117 ms 632 KB Output is correct
31 Correct 154 ms 632 KB Output is correct
32 Correct 109 ms 668 KB Output is correct
33 Correct 8 ms 712 KB Output is correct
34 Correct 8 ms 632 KB Output is correct
35 Correct 61 ms 640 KB Output is correct
36 Correct 103 ms 632 KB Output is correct
37 Runtime error 4 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 9 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 4 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 4 ms 376 KB Output is correct
15 Correct 4 ms 376 KB Output is correct
16 Correct 4 ms 380 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 4 ms 380 KB Output is correct
19 Correct 4 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 47 ms 504 KB Output is correct
22 Correct 63 ms 504 KB Output is correct
23 Correct 28 ms 632 KB Output is correct
24 Correct 93 ms 632 KB Output is correct
25 Correct 100 ms 616 KB Output is correct
26 Correct 118 ms 632 KB Output is correct
27 Correct 81 ms 632 KB Output is correct
28 Correct 64 ms 632 KB Output is correct
29 Correct 81 ms 732 KB Output is correct
30 Correct 117 ms 632 KB Output is correct
31 Correct 154 ms 632 KB Output is correct
32 Correct 109 ms 668 KB Output is correct
33 Correct 8 ms 712 KB Output is correct
34 Correct 8 ms 632 KB Output is correct
35 Correct 61 ms 640 KB Output is correct
36 Correct 103 ms 632 KB Output is correct
37 Runtime error 4 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Halted 0 ms 0 KB -