답안 #854064

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
854064 2023-09-26T04:35:43 Z The_Samurai Bootfall (IZhO17_bootfall) C++17
100 / 100
241 ms 17616 KB
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const ll inf = 1e18;
const int N = 250001, sq = 23;

int main() {
    cin.tie(0)->sync_with_stdio(false);
#ifdef sunnatov
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n, sum = 0;
    cin >> n;
    vector<int> a(n);
    for (int &x: a) cin >> x;
    vector<bitset<N>> without(sq);
    bitset<N> bs; bs.set(0);
    for (int x: a) bs |= bs << x;
    for (int i = 0; i < sq; i++) {
        without[i].set(0);
        for (int j = 0; j < n; j++) {
            if (i * sq <= j and j < (i + 1) * sq) continue;
            without[i] |= without[i] << a[j];
        }
    }
    vector<bitset<N>> without_2(n);
    for (int i = 0; i < n; i++) {
        sum += a[i];
        without_2[i] = without[i / sq];
        for (int j = i - i % sq; j < min(n, i - i % sq + sq); j++) {
            if (i == j) continue;
            without_2[i] |= without_2[i] << a[j];
        }
    }
    vector<int> ans;
    for (int i = 1; i < N; i++) {
        if (sum % 2 or !bs[sum / 2]) continue;
        sum += i;
        bool ok = true;
        for (int j = 0; j < n and ok; j++) {
            sum -= a[j];
            if (sum % 2 or !without_2[j][sum / 2]) ok = false;
            sum += a[j];
        }
        sum -= i;
        if (ok) ans.emplace_back(i);
    }
    cout << ans.size() << '\n';
    for (int x: ans) cout << x << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1368 KB Output is correct
2 Correct 3 ms 1368 KB Output is correct
3 Correct 2 ms 1112 KB Output is correct
4 Correct 2 ms 1368 KB Output is correct
5 Correct 4 ms 1624 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 3 ms 1368 KB Output is correct
8 Correct 4 ms 1624 KB Output is correct
9 Correct 3 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1368 KB Output is correct
2 Correct 3 ms 1368 KB Output is correct
3 Correct 2 ms 1112 KB Output is correct
4 Correct 2 ms 1368 KB Output is correct
5 Correct 4 ms 1624 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 3 ms 1368 KB Output is correct
8 Correct 4 ms 1624 KB Output is correct
9 Correct 3 ms 1368 KB Output is correct
10 Correct 10 ms 2140 KB Output is correct
11 Correct 10 ms 2136 KB Output is correct
12 Correct 10 ms 2136 KB Output is correct
13 Correct 9 ms 1884 KB Output is correct
14 Correct 9 ms 1880 KB Output is correct
15 Correct 10 ms 1880 KB Output is correct
16 Correct 11 ms 2032 KB Output is correct
17 Correct 6 ms 1624 KB Output is correct
18 Correct 10 ms 1884 KB Output is correct
19 Correct 9 ms 1880 KB Output is correct
20 Correct 10 ms 2136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1368 KB Output is correct
2 Correct 3 ms 1368 KB Output is correct
3 Correct 2 ms 1112 KB Output is correct
4 Correct 2 ms 1368 KB Output is correct
5 Correct 4 ms 1624 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 3 ms 1368 KB Output is correct
8 Correct 4 ms 1624 KB Output is correct
9 Correct 3 ms 1368 KB Output is correct
10 Correct 10 ms 2140 KB Output is correct
11 Correct 10 ms 2136 KB Output is correct
12 Correct 10 ms 2136 KB Output is correct
13 Correct 9 ms 1884 KB Output is correct
14 Correct 9 ms 1880 KB Output is correct
15 Correct 10 ms 1880 KB Output is correct
16 Correct 11 ms 2032 KB Output is correct
17 Correct 6 ms 1624 KB Output is correct
18 Correct 10 ms 1884 KB Output is correct
19 Correct 9 ms 1880 KB Output is correct
20 Correct 10 ms 2136 KB Output is correct
21 Correct 20 ms 3160 KB Output is correct
22 Correct 24 ms 3416 KB Output is correct
23 Correct 16 ms 2648 KB Output is correct
24 Correct 30 ms 4132 KB Output is correct
25 Correct 30 ms 3928 KB Output is correct
26 Correct 33 ms 4300 KB Output is correct
27 Correct 31 ms 4072 KB Output is correct
28 Correct 31 ms 4184 KB Output is correct
29 Correct 34 ms 4336 KB Output is correct
30 Correct 31 ms 4440 KB Output is correct
31 Correct 33 ms 4184 KB Output is correct
32 Correct 31 ms 4184 KB Output is correct
33 Correct 31 ms 4176 KB Output is correct
34 Correct 31 ms 4068 KB Output is correct
35 Correct 32 ms 4184 KB Output is correct
36 Correct 31 ms 4580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1368 KB Output is correct
2 Correct 3 ms 1368 KB Output is correct
3 Correct 2 ms 1112 KB Output is correct
4 Correct 2 ms 1368 KB Output is correct
5 Correct 4 ms 1624 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 3 ms 1368 KB Output is correct
8 Correct 4 ms 1624 KB Output is correct
9 Correct 3 ms 1368 KB Output is correct
10 Correct 10 ms 2140 KB Output is correct
11 Correct 10 ms 2136 KB Output is correct
12 Correct 10 ms 2136 KB Output is correct
13 Correct 9 ms 1884 KB Output is correct
14 Correct 9 ms 1880 KB Output is correct
15 Correct 10 ms 1880 KB Output is correct
16 Correct 11 ms 2032 KB Output is correct
17 Correct 6 ms 1624 KB Output is correct
18 Correct 10 ms 1884 KB Output is correct
19 Correct 9 ms 1880 KB Output is correct
20 Correct 10 ms 2136 KB Output is correct
21 Correct 20 ms 3160 KB Output is correct
22 Correct 24 ms 3416 KB Output is correct
23 Correct 16 ms 2648 KB Output is correct
24 Correct 30 ms 4132 KB Output is correct
25 Correct 30 ms 3928 KB Output is correct
26 Correct 33 ms 4300 KB Output is correct
27 Correct 31 ms 4072 KB Output is correct
28 Correct 31 ms 4184 KB Output is correct
29 Correct 34 ms 4336 KB Output is correct
30 Correct 31 ms 4440 KB Output is correct
31 Correct 33 ms 4184 KB Output is correct
32 Correct 31 ms 4184 KB Output is correct
33 Correct 31 ms 4176 KB Output is correct
34 Correct 31 ms 4068 KB Output is correct
35 Correct 32 ms 4184 KB Output is correct
36 Correct 31 ms 4580 KB Output is correct
37 Correct 64 ms 7356 KB Output is correct
38 Correct 65 ms 7360 KB Output is correct
39 Correct 77 ms 8784 KB Output is correct
40 Correct 93 ms 9680 KB Output is correct
41 Correct 82 ms 9296 KB Output is correct
42 Correct 88 ms 9040 KB Output is correct
43 Correct 85 ms 9040 KB Output is correct
44 Correct 85 ms 9184 KB Output is correct
45 Correct 87 ms 9188 KB Output is correct
46 Correct 82 ms 9500 KB Output is correct
47 Correct 83 ms 8932 KB Output is correct
48 Correct 84 ms 9172 KB Output is correct
49 Correct 80 ms 8784 KB Output is correct
50 Correct 82 ms 8916 KB Output is correct
51 Correct 76 ms 8784 KB Output is correct
52 Correct 102 ms 9704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1368 KB Output is correct
2 Correct 3 ms 1368 KB Output is correct
3 Correct 2 ms 1112 KB Output is correct
4 Correct 2 ms 1368 KB Output is correct
5 Correct 4 ms 1624 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 3 ms 1368 KB Output is correct
8 Correct 4 ms 1624 KB Output is correct
9 Correct 3 ms 1368 KB Output is correct
10 Correct 10 ms 2140 KB Output is correct
11 Correct 10 ms 2136 KB Output is correct
12 Correct 10 ms 2136 KB Output is correct
13 Correct 9 ms 1884 KB Output is correct
14 Correct 9 ms 1880 KB Output is correct
15 Correct 10 ms 1880 KB Output is correct
16 Correct 11 ms 2032 KB Output is correct
17 Correct 6 ms 1624 KB Output is correct
18 Correct 10 ms 1884 KB Output is correct
19 Correct 9 ms 1880 KB Output is correct
20 Correct 10 ms 2136 KB Output is correct
21 Correct 20 ms 3160 KB Output is correct
22 Correct 24 ms 3416 KB Output is correct
23 Correct 16 ms 2648 KB Output is correct
24 Correct 30 ms 4132 KB Output is correct
25 Correct 30 ms 3928 KB Output is correct
26 Correct 33 ms 4300 KB Output is correct
27 Correct 31 ms 4072 KB Output is correct
28 Correct 31 ms 4184 KB Output is correct
29 Correct 34 ms 4336 KB Output is correct
30 Correct 31 ms 4440 KB Output is correct
31 Correct 33 ms 4184 KB Output is correct
32 Correct 31 ms 4184 KB Output is correct
33 Correct 31 ms 4176 KB Output is correct
34 Correct 31 ms 4068 KB Output is correct
35 Correct 32 ms 4184 KB Output is correct
36 Correct 31 ms 4580 KB Output is correct
37 Correct 64 ms 7356 KB Output is correct
38 Correct 65 ms 7360 KB Output is correct
39 Correct 77 ms 8784 KB Output is correct
40 Correct 93 ms 9680 KB Output is correct
41 Correct 82 ms 9296 KB Output is correct
42 Correct 88 ms 9040 KB Output is correct
43 Correct 85 ms 9040 KB Output is correct
44 Correct 85 ms 9184 KB Output is correct
45 Correct 87 ms 9188 KB Output is correct
46 Correct 82 ms 9500 KB Output is correct
47 Correct 83 ms 8932 KB Output is correct
48 Correct 84 ms 9172 KB Output is correct
49 Correct 80 ms 8784 KB Output is correct
50 Correct 82 ms 8916 KB Output is correct
51 Correct 76 ms 8784 KB Output is correct
52 Correct 102 ms 9704 KB Output is correct
53 Correct 106 ms 10672 KB Output is correct
54 Correct 134 ms 12112 KB Output is correct
55 Correct 136 ms 12452 KB Output is correct
56 Correct 108 ms 10832 KB Output is correct
57 Correct 137 ms 12584 KB Output is correct
58 Correct 122 ms 12200 KB Output is correct
59 Correct 128 ms 12244 KB Output is correct
60 Correct 106 ms 11856 KB Output is correct
61 Correct 139 ms 12324 KB Output is correct
62 Correct 123 ms 11476 KB Output is correct
63 Correct 123 ms 11476 KB Output is correct
64 Correct 118 ms 11220 KB Output is correct
65 Correct 102 ms 11088 KB Output is correct
66 Correct 96 ms 10576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1368 KB Output is correct
2 Correct 3 ms 1368 KB Output is correct
3 Correct 2 ms 1112 KB Output is correct
4 Correct 2 ms 1368 KB Output is correct
5 Correct 4 ms 1624 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 3 ms 1368 KB Output is correct
8 Correct 4 ms 1624 KB Output is correct
9 Correct 3 ms 1368 KB Output is correct
10 Correct 10 ms 2140 KB Output is correct
11 Correct 10 ms 2136 KB Output is correct
12 Correct 10 ms 2136 KB Output is correct
13 Correct 9 ms 1884 KB Output is correct
14 Correct 9 ms 1880 KB Output is correct
15 Correct 10 ms 1880 KB Output is correct
16 Correct 11 ms 2032 KB Output is correct
17 Correct 6 ms 1624 KB Output is correct
18 Correct 10 ms 1884 KB Output is correct
19 Correct 9 ms 1880 KB Output is correct
20 Correct 10 ms 2136 KB Output is correct
21 Correct 20 ms 3160 KB Output is correct
22 Correct 24 ms 3416 KB Output is correct
23 Correct 16 ms 2648 KB Output is correct
24 Correct 30 ms 4132 KB Output is correct
25 Correct 30 ms 3928 KB Output is correct
26 Correct 33 ms 4300 KB Output is correct
27 Correct 31 ms 4072 KB Output is correct
28 Correct 31 ms 4184 KB Output is correct
29 Correct 34 ms 4336 KB Output is correct
30 Correct 31 ms 4440 KB Output is correct
31 Correct 33 ms 4184 KB Output is correct
32 Correct 31 ms 4184 KB Output is correct
33 Correct 31 ms 4176 KB Output is correct
34 Correct 31 ms 4068 KB Output is correct
35 Correct 32 ms 4184 KB Output is correct
36 Correct 31 ms 4580 KB Output is correct
37 Correct 64 ms 7356 KB Output is correct
38 Correct 65 ms 7360 KB Output is correct
39 Correct 77 ms 8784 KB Output is correct
40 Correct 93 ms 9680 KB Output is correct
41 Correct 82 ms 9296 KB Output is correct
42 Correct 88 ms 9040 KB Output is correct
43 Correct 85 ms 9040 KB Output is correct
44 Correct 85 ms 9184 KB Output is correct
45 Correct 87 ms 9188 KB Output is correct
46 Correct 82 ms 9500 KB Output is correct
47 Correct 83 ms 8932 KB Output is correct
48 Correct 84 ms 9172 KB Output is correct
49 Correct 80 ms 8784 KB Output is correct
50 Correct 82 ms 8916 KB Output is correct
51 Correct 76 ms 8784 KB Output is correct
52 Correct 102 ms 9704 KB Output is correct
53 Correct 106 ms 10672 KB Output is correct
54 Correct 134 ms 12112 KB Output is correct
55 Correct 136 ms 12452 KB Output is correct
56 Correct 108 ms 10832 KB Output is correct
57 Correct 137 ms 12584 KB Output is correct
58 Correct 122 ms 12200 KB Output is correct
59 Correct 128 ms 12244 KB Output is correct
60 Correct 106 ms 11856 KB Output is correct
61 Correct 139 ms 12324 KB Output is correct
62 Correct 123 ms 11476 KB Output is correct
63 Correct 123 ms 11476 KB Output is correct
64 Correct 118 ms 11220 KB Output is correct
65 Correct 102 ms 11088 KB Output is correct
66 Correct 96 ms 10576 KB Output is correct
67 Correct 155 ms 13892 KB Output is correct
68 Correct 153 ms 16532 KB Output is correct
69 Correct 237 ms 17484 KB Output is correct
70 Correct 205 ms 17236 KB Output is correct
71 Correct 202 ms 17104 KB Output is correct
72 Correct 153 ms 16532 KB Output is correct
73 Correct 152 ms 16464 KB Output is correct
74 Correct 241 ms 17616 KB Output is correct
75 Correct 217 ms 17364 KB Output is correct
76 Correct 238 ms 17488 KB Output is correct
77 Correct 236 ms 17612 KB Output is correct