Submission #682657

# Submission time Handle Problem Language Result Execution time Memory
682657 2023-01-16T17:26:10 Z opPO Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 1700 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("sse4,avx2,fma,avx")
#include <bits/stdc++.h>

using namespace std;

#define f first
#define s second
#define pb push_back
#define ld long double
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define vec vector

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
const ld eps = 1e-6;
const int mod = 998244353;
const int oo = 2e9;
const ll OO = 2e18;
const int N = 250001;
int n;
bitset<N> can;

void backpack(vec<int> &a)
{
    can.reset();
    can[0] = 1;
    for (int i = 1; i <= n; i++) can |= can << a[i];
}

void solve()
{
    cin >> n;
    vec<int> a(n + 1);
    int s = 0;
    for (int i = 1; i <= n; i++) cin >> a[i], s += a[i];
    backpack(a);
    if (!can[s / 2])
    {
        cout << 0;
        return;
    }
    vec<int> cnt(500 * n + 1);
    for (int i = 1; i <= n; i++)
    {
        int t = a[i];
        a[i] = 0;
        backpack(a);
        a[i] = t;
        int from = (s - a[i]) % 2 ? 1 : 2;
        for (int j = from; j <= 500 * n; j += 2)
        {
            if (can[(s - a[i] + j) / 2]) cnt[j]++;
        }
    }
    vec<int> ans;
    for (int i = 1; i <= 500 * n; i++) if (cnt[i] == n) ans.pb(i);
    cout << sz(ans) << "\n";
    for (int &x : ans) cout << x << " ";
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 6 ms 468 KB Output is correct
11 Correct 6 ms 476 KB Output is correct
12 Correct 6 ms 468 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 5 ms 340 KB Output is correct
16 Correct 6 ms 468 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 6 ms 456 KB Output is correct
19 Correct 5 ms 452 KB Output is correct
20 Correct 6 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 6 ms 468 KB Output is correct
11 Correct 6 ms 476 KB Output is correct
12 Correct 6 ms 468 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 5 ms 340 KB Output is correct
16 Correct 6 ms 468 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 6 ms 456 KB Output is correct
19 Correct 5 ms 452 KB Output is correct
20 Correct 6 ms 468 KB Output is correct
21 Correct 25 ms 520 KB Output is correct
22 Correct 33 ms 564 KB Output is correct
23 Correct 15 ms 504 KB Output is correct
24 Correct 51 ms 596 KB Output is correct
25 Correct 53 ms 596 KB Output is correct
26 Correct 62 ms 600 KB Output is correct
27 Correct 68 ms 600 KB Output is correct
28 Correct 73 ms 596 KB Output is correct
29 Correct 61 ms 600 KB Output is correct
30 Correct 61 ms 596 KB Output is correct
31 Correct 61 ms 600 KB Output is correct
32 Correct 59 ms 596 KB Output is correct
33 Correct 58 ms 596 KB Output is correct
34 Correct 57 ms 596 KB Output is correct
35 Correct 57 ms 596 KB Output is correct
36 Correct 57 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 6 ms 468 KB Output is correct
11 Correct 6 ms 476 KB Output is correct
12 Correct 6 ms 468 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 5 ms 340 KB Output is correct
16 Correct 6 ms 468 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 6 ms 456 KB Output is correct
19 Correct 5 ms 452 KB Output is correct
20 Correct 6 ms 468 KB Output is correct
21 Correct 25 ms 520 KB Output is correct
22 Correct 33 ms 564 KB Output is correct
23 Correct 15 ms 504 KB Output is correct
24 Correct 51 ms 596 KB Output is correct
25 Correct 53 ms 596 KB Output is correct
26 Correct 62 ms 600 KB Output is correct
27 Correct 68 ms 600 KB Output is correct
28 Correct 73 ms 596 KB Output is correct
29 Correct 61 ms 600 KB Output is correct
30 Correct 61 ms 596 KB Output is correct
31 Correct 61 ms 600 KB Output is correct
32 Correct 59 ms 596 KB Output is correct
33 Correct 58 ms 596 KB Output is correct
34 Correct 57 ms 596 KB Output is correct
35 Correct 57 ms 596 KB Output is correct
36 Correct 57 ms 596 KB Output is correct
37 Correct 242 ms 920 KB Output is correct
38 Correct 248 ms 916 KB Output is correct
39 Correct 358 ms 884 KB Output is correct
40 Correct 449 ms 1056 KB Output is correct
41 Correct 411 ms 852 KB Output is correct
42 Correct 407 ms 1100 KB Output is correct
43 Correct 342 ms 1264 KB Output is correct
44 Correct 364 ms 1280 KB Output is correct
45 Correct 355 ms 1292 KB Output is correct
46 Correct 424 ms 836 KB Output is correct
47 Correct 360 ms 1020 KB Output is correct
48 Correct 363 ms 1144 KB Output is correct
49 Correct 357 ms 972 KB Output is correct
50 Correct 370 ms 1020 KB Output is correct
51 Correct 370 ms 852 KB Output is correct
52 Correct 433 ms 1312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 6 ms 468 KB Output is correct
11 Correct 6 ms 476 KB Output is correct
12 Correct 6 ms 468 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 5 ms 340 KB Output is correct
16 Correct 6 ms 468 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 6 ms 456 KB Output is correct
19 Correct 5 ms 452 KB Output is correct
20 Correct 6 ms 468 KB Output is correct
21 Correct 25 ms 520 KB Output is correct
22 Correct 33 ms 564 KB Output is correct
23 Correct 15 ms 504 KB Output is correct
24 Correct 51 ms 596 KB Output is correct
25 Correct 53 ms 596 KB Output is correct
26 Correct 62 ms 600 KB Output is correct
27 Correct 68 ms 600 KB Output is correct
28 Correct 73 ms 596 KB Output is correct
29 Correct 61 ms 600 KB Output is correct
30 Correct 61 ms 596 KB Output is correct
31 Correct 61 ms 600 KB Output is correct
32 Correct 59 ms 596 KB Output is correct
33 Correct 58 ms 596 KB Output is correct
34 Correct 57 ms 596 KB Output is correct
35 Correct 57 ms 596 KB Output is correct
36 Correct 57 ms 596 KB Output is correct
37 Correct 242 ms 920 KB Output is correct
38 Correct 248 ms 916 KB Output is correct
39 Correct 358 ms 884 KB Output is correct
40 Correct 449 ms 1056 KB Output is correct
41 Correct 411 ms 852 KB Output is correct
42 Correct 407 ms 1100 KB Output is correct
43 Correct 342 ms 1264 KB Output is correct
44 Correct 364 ms 1280 KB Output is correct
45 Correct 355 ms 1292 KB Output is correct
46 Correct 424 ms 836 KB Output is correct
47 Correct 360 ms 1020 KB Output is correct
48 Correct 363 ms 1144 KB Output is correct
49 Correct 357 ms 972 KB Output is correct
50 Correct 370 ms 1020 KB Output is correct
51 Correct 370 ms 852 KB Output is correct
52 Correct 433 ms 1312 KB Output is correct
53 Correct 562 ms 1228 KB Output is correct
54 Correct 714 ms 1484 KB Output is correct
55 Correct 727 ms 1600 KB Output is correct
56 Correct 569 ms 1388 KB Output is correct
57 Correct 721 ms 1620 KB Output is correct
58 Correct 697 ms 1476 KB Output is correct
59 Correct 719 ms 1472 KB Output is correct
60 Correct 724 ms 980 KB Output is correct
61 Correct 710 ms 1604 KB Output is correct
62 Correct 598 ms 1544 KB Output is correct
63 Correct 596 ms 1544 KB Output is correct
64 Correct 569 ms 1532 KB Output is correct
65 Correct 572 ms 1024 KB Output is correct
66 Correct 547 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 6 ms 468 KB Output is correct
11 Correct 6 ms 476 KB Output is correct
12 Correct 6 ms 468 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 5 ms 340 KB Output is correct
16 Correct 6 ms 468 KB Output is correct
17 Correct 2 ms 332 KB Output is correct
18 Correct 6 ms 456 KB Output is correct
19 Correct 5 ms 452 KB Output is correct
20 Correct 6 ms 468 KB Output is correct
21 Correct 25 ms 520 KB Output is correct
22 Correct 33 ms 564 KB Output is correct
23 Correct 15 ms 504 KB Output is correct
24 Correct 51 ms 596 KB Output is correct
25 Correct 53 ms 596 KB Output is correct
26 Correct 62 ms 600 KB Output is correct
27 Correct 68 ms 600 KB Output is correct
28 Correct 73 ms 596 KB Output is correct
29 Correct 61 ms 600 KB Output is correct
30 Correct 61 ms 596 KB Output is correct
31 Correct 61 ms 600 KB Output is correct
32 Correct 59 ms 596 KB Output is correct
33 Correct 58 ms 596 KB Output is correct
34 Correct 57 ms 596 KB Output is correct
35 Correct 57 ms 596 KB Output is correct
36 Correct 57 ms 596 KB Output is correct
37 Correct 242 ms 920 KB Output is correct
38 Correct 248 ms 916 KB Output is correct
39 Correct 358 ms 884 KB Output is correct
40 Correct 449 ms 1056 KB Output is correct
41 Correct 411 ms 852 KB Output is correct
42 Correct 407 ms 1100 KB Output is correct
43 Correct 342 ms 1264 KB Output is correct
44 Correct 364 ms 1280 KB Output is correct
45 Correct 355 ms 1292 KB Output is correct
46 Correct 424 ms 836 KB Output is correct
47 Correct 360 ms 1020 KB Output is correct
48 Correct 363 ms 1144 KB Output is correct
49 Correct 357 ms 972 KB Output is correct
50 Correct 370 ms 1020 KB Output is correct
51 Correct 370 ms 852 KB Output is correct
52 Correct 433 ms 1312 KB Output is correct
53 Correct 562 ms 1228 KB Output is correct
54 Correct 714 ms 1484 KB Output is correct
55 Correct 727 ms 1600 KB Output is correct
56 Correct 569 ms 1388 KB Output is correct
57 Correct 721 ms 1620 KB Output is correct
58 Correct 697 ms 1476 KB Output is correct
59 Correct 719 ms 1472 KB Output is correct
60 Correct 724 ms 980 KB Output is correct
61 Correct 710 ms 1604 KB Output is correct
62 Correct 598 ms 1544 KB Output is correct
63 Correct 596 ms 1544 KB Output is correct
64 Correct 569 ms 1532 KB Output is correct
65 Correct 572 ms 1024 KB Output is correct
66 Correct 547 ms 1100 KB Output is correct
67 Correct 949 ms 1700 KB Output is correct
68 Correct 4 ms 340 KB Output is correct
69 Execution timed out 1090 ms 1348 KB Time limit exceeded
70 Halted 0 ms 0 KB -