답안 #464878

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464878 2021-08-14T11:05:34 Z TeaTime Bootfall (IZhO17_bootfall) C++17
13 / 100
1000 ms 6736 KB
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <bitset>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

#define int ll
const ll INF = 1e9, SZ = 510 * 510, SZ2 = 510;

ll n;
vector<ll> vec;
bitset<SZ> bts;
bitset<SZ> pref[SZ2], suf[SZ2], un[SZ2];

signed main() {
    fastInp;

    cin >> n;
    vec.resize(n);

    for (auto& c : vec) cin >> c;

    bts[0] = 1;
    ll sm = 0;

    pref[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        pref[i] = (pref[i - 1] | (pref[i - 1] << vec[i - 1]));
    }

    suf[n][0] = 1;
    for (int i = n - 1; i >= 0; i--) {
        suf[i] = (suf[i + 1] | (suf[i + 1] << vec[i]));
    }

    for (int i = n - 1; i >= 0; i--) {
        for (int j = 0; j < SZ; j++) {
            if (pref[i][j]) un[i] |= (suf[i + 1] << j);
        }
    }

    for (auto c : vec) {
        sm += c;
        bts |= (bts << c);
    }

    if (sm % 2) {
        cout << "0";
        return 0;
    }

    if (bts[sm / 2] != 1) {
        cout << "0";
        return 0;
    }

    vector<ll> ans;

    for (int i = 1; i < SZ; i++) {
        bool f = 1;
        for (int j = 0; j < n; j++) {
            ll cursm = sm - vec[j] + i;
            if (cursm % 2) {
                f = 0;
                break;
            }

            cursm /= 2;
            if (i > cursm) {
                f = 0;
                break;
            }

            if (!un[j][cursm - i]) {
                f = 0;
                break;
            }
        }

        if (f) ans.push_back(i);
    }

    cout << ans.size() << "\n";
    for (auto c : ans) cout << c << " ";
   
    return 0;
}

/*
3 4
RGWR
GRGG
RGWW

4 4
RGWR
GRRG
WGGW
WWWR

5 5
RGRGW
GRRGW
WGGWR
RWRGW
RGWGW
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 716 KB Output is correct
2 Correct 4 ms 972 KB Output is correct
3 Correct 2 ms 716 KB Output is correct
4 Correct 3 ms 716 KB Output is correct
5 Correct 22 ms 1492 KB Output is correct
6 Correct 6 ms 1100 KB Output is correct
7 Correct 4 ms 972 KB Output is correct
8 Correct 20 ms 1484 KB Output is correct
9 Correct 12 ms 1284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 716 KB Output is correct
2 Correct 4 ms 972 KB Output is correct
3 Correct 2 ms 716 KB Output is correct
4 Correct 3 ms 716 KB Output is correct
5 Correct 22 ms 1492 KB Output is correct
6 Correct 6 ms 1100 KB Output is correct
7 Correct 4 ms 972 KB Output is correct
8 Correct 20 ms 1484 KB Output is correct
9 Correct 12 ms 1284 KB Output is correct
10 Correct 22 ms 3248 KB Output is correct
11 Correct 47 ms 3232 KB Output is correct
12 Correct 37 ms 3280 KB Output is correct
13 Correct 37 ms 2848 KB Output is correct
14 Correct 46 ms 3104 KB Output is correct
15 Correct 34 ms 3064 KB Output is correct
16 Correct 40 ms 3232 KB Output is correct
17 Correct 19 ms 2048 KB Output is correct
18 Correct 35 ms 2636 KB Output is correct
19 Correct 44 ms 2800 KB Output is correct
20 Correct 16 ms 3292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 716 KB Output is correct
2 Correct 4 ms 972 KB Output is correct
3 Correct 2 ms 716 KB Output is correct
4 Correct 3 ms 716 KB Output is correct
5 Correct 22 ms 1492 KB Output is correct
6 Correct 6 ms 1100 KB Output is correct
7 Correct 4 ms 972 KB Output is correct
8 Correct 20 ms 1484 KB Output is correct
9 Correct 12 ms 1284 KB Output is correct
10 Correct 22 ms 3248 KB Output is correct
11 Correct 47 ms 3232 KB Output is correct
12 Correct 37 ms 3280 KB Output is correct
13 Correct 37 ms 2848 KB Output is correct
14 Correct 46 ms 3104 KB Output is correct
15 Correct 34 ms 3064 KB Output is correct
16 Correct 40 ms 3232 KB Output is correct
17 Correct 19 ms 2048 KB Output is correct
18 Correct 35 ms 2636 KB Output is correct
19 Correct 44 ms 2800 KB Output is correct
20 Correct 16 ms 3292 KB Output is correct
21 Correct 922 ms 6476 KB Output is correct
22 Execution timed out 1079 ms 6736 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 716 KB Output is correct
2 Correct 4 ms 972 KB Output is correct
3 Correct 2 ms 716 KB Output is correct
4 Correct 3 ms 716 KB Output is correct
5 Correct 22 ms 1492 KB Output is correct
6 Correct 6 ms 1100 KB Output is correct
7 Correct 4 ms 972 KB Output is correct
8 Correct 20 ms 1484 KB Output is correct
9 Correct 12 ms 1284 KB Output is correct
10 Correct 22 ms 3248 KB Output is correct
11 Correct 47 ms 3232 KB Output is correct
12 Correct 37 ms 3280 KB Output is correct
13 Correct 37 ms 2848 KB Output is correct
14 Correct 46 ms 3104 KB Output is correct
15 Correct 34 ms 3064 KB Output is correct
16 Correct 40 ms 3232 KB Output is correct
17 Correct 19 ms 2048 KB Output is correct
18 Correct 35 ms 2636 KB Output is correct
19 Correct 44 ms 2800 KB Output is correct
20 Correct 16 ms 3292 KB Output is correct
21 Correct 922 ms 6476 KB Output is correct
22 Execution timed out 1079 ms 6736 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 716 KB Output is correct
2 Correct 4 ms 972 KB Output is correct
3 Correct 2 ms 716 KB Output is correct
4 Correct 3 ms 716 KB Output is correct
5 Correct 22 ms 1492 KB Output is correct
6 Correct 6 ms 1100 KB Output is correct
7 Correct 4 ms 972 KB Output is correct
8 Correct 20 ms 1484 KB Output is correct
9 Correct 12 ms 1284 KB Output is correct
10 Correct 22 ms 3248 KB Output is correct
11 Correct 47 ms 3232 KB Output is correct
12 Correct 37 ms 3280 KB Output is correct
13 Correct 37 ms 2848 KB Output is correct
14 Correct 46 ms 3104 KB Output is correct
15 Correct 34 ms 3064 KB Output is correct
16 Correct 40 ms 3232 KB Output is correct
17 Correct 19 ms 2048 KB Output is correct
18 Correct 35 ms 2636 KB Output is correct
19 Correct 44 ms 2800 KB Output is correct
20 Correct 16 ms 3292 KB Output is correct
21 Correct 922 ms 6476 KB Output is correct
22 Execution timed out 1079 ms 6736 KB Time limit exceeded
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 716 KB Output is correct
2 Correct 4 ms 972 KB Output is correct
3 Correct 2 ms 716 KB Output is correct
4 Correct 3 ms 716 KB Output is correct
5 Correct 22 ms 1492 KB Output is correct
6 Correct 6 ms 1100 KB Output is correct
7 Correct 4 ms 972 KB Output is correct
8 Correct 20 ms 1484 KB Output is correct
9 Correct 12 ms 1284 KB Output is correct
10 Correct 22 ms 3248 KB Output is correct
11 Correct 47 ms 3232 KB Output is correct
12 Correct 37 ms 3280 KB Output is correct
13 Correct 37 ms 2848 KB Output is correct
14 Correct 46 ms 3104 KB Output is correct
15 Correct 34 ms 3064 KB Output is correct
16 Correct 40 ms 3232 KB Output is correct
17 Correct 19 ms 2048 KB Output is correct
18 Correct 35 ms 2636 KB Output is correct
19 Correct 44 ms 2800 KB Output is correct
20 Correct 16 ms 3292 KB Output is correct
21 Correct 922 ms 6476 KB Output is correct
22 Execution timed out 1079 ms 6736 KB Time limit exceeded
23 Halted 0 ms 0 KB -