Submission #682113

# Submission time Handle Problem Language Result Execution time Memory
682113 2023-01-15T19:57:02 Z opPO Bootfall (IZhO17_bootfall) C++17
65 / 100
1000 ms 1740 KB
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>

using namespace std;

//#define int long long
#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 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 7 ms 456 KB Output is correct
11 Correct 5 ms 468 KB Output is correct
12 Correct 5 ms 480 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 7 ms 340 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 4 ms 340 KB Output is correct
19 Correct 4 ms 340 KB Output is correct
20 Correct 5 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 7 ms 456 KB Output is correct
11 Correct 5 ms 468 KB Output is correct
12 Correct 5 ms 480 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 7 ms 340 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 4 ms 340 KB Output is correct
19 Correct 4 ms 340 KB Output is correct
20 Correct 5 ms 468 KB Output is correct
21 Correct 23 ms 524 KB Output is correct
22 Correct 29 ms 560 KB Output is correct
23 Correct 14 ms 504 KB Output is correct
24 Correct 46 ms 584 KB Output is correct
25 Correct 54 ms 596 KB Output is correct
26 Correct 52 ms 604 KB Output is correct
27 Correct 52 ms 592 KB Output is correct
28 Correct 60 ms 600 KB Output is correct
29 Correct 52 ms 596 KB Output is correct
30 Correct 51 ms 596 KB Output is correct
31 Correct 52 ms 596 KB Output is correct
32 Correct 56 ms 600 KB Output is correct
33 Correct 56 ms 596 KB Output is correct
34 Correct 54 ms 596 KB Output is correct
35 Correct 54 ms 596 KB Output is correct
36 Correct 55 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 7 ms 456 KB Output is correct
11 Correct 5 ms 468 KB Output is correct
12 Correct 5 ms 480 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 7 ms 340 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 4 ms 340 KB Output is correct
19 Correct 4 ms 340 KB Output is correct
20 Correct 5 ms 468 KB Output is correct
21 Correct 23 ms 524 KB Output is correct
22 Correct 29 ms 560 KB Output is correct
23 Correct 14 ms 504 KB Output is correct
24 Correct 46 ms 584 KB Output is correct
25 Correct 54 ms 596 KB Output is correct
26 Correct 52 ms 604 KB Output is correct
27 Correct 52 ms 592 KB Output is correct
28 Correct 60 ms 600 KB Output is correct
29 Correct 52 ms 596 KB Output is correct
30 Correct 51 ms 596 KB Output is correct
31 Correct 52 ms 596 KB Output is correct
32 Correct 56 ms 600 KB Output is correct
33 Correct 56 ms 596 KB Output is correct
34 Correct 54 ms 596 KB Output is correct
35 Correct 54 ms 596 KB Output is correct
36 Correct 55 ms 608 KB Output is correct
37 Correct 206 ms 920 KB Output is correct
38 Correct 205 ms 924 KB Output is correct
39 Correct 322 ms 852 KB Output is correct
40 Correct 380 ms 1052 KB Output is correct
41 Correct 372 ms 936 KB Output is correct
42 Correct 314 ms 1020 KB Output is correct
43 Correct 316 ms 1260 KB Output is correct
44 Correct 319 ms 1268 KB Output is correct
45 Correct 354 ms 1276 KB Output is correct
46 Correct 361 ms 852 KB Output is correct
47 Correct 348 ms 1100 KB Output is correct
48 Correct 318 ms 1148 KB Output is correct
49 Correct 328 ms 896 KB Output is correct
50 Correct 344 ms 1020 KB Output is correct
51 Correct 311 ms 852 KB Output is correct
52 Correct 386 ms 1312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 7 ms 456 KB Output is correct
11 Correct 5 ms 468 KB Output is correct
12 Correct 5 ms 480 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 7 ms 340 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 4 ms 340 KB Output is correct
19 Correct 4 ms 340 KB Output is correct
20 Correct 5 ms 468 KB Output is correct
21 Correct 23 ms 524 KB Output is correct
22 Correct 29 ms 560 KB Output is correct
23 Correct 14 ms 504 KB Output is correct
24 Correct 46 ms 584 KB Output is correct
25 Correct 54 ms 596 KB Output is correct
26 Correct 52 ms 604 KB Output is correct
27 Correct 52 ms 592 KB Output is correct
28 Correct 60 ms 600 KB Output is correct
29 Correct 52 ms 596 KB Output is correct
30 Correct 51 ms 596 KB Output is correct
31 Correct 52 ms 596 KB Output is correct
32 Correct 56 ms 600 KB Output is correct
33 Correct 56 ms 596 KB Output is correct
34 Correct 54 ms 596 KB Output is correct
35 Correct 54 ms 596 KB Output is correct
36 Correct 55 ms 608 KB Output is correct
37 Correct 206 ms 920 KB Output is correct
38 Correct 205 ms 924 KB Output is correct
39 Correct 322 ms 852 KB Output is correct
40 Correct 380 ms 1052 KB Output is correct
41 Correct 372 ms 936 KB Output is correct
42 Correct 314 ms 1020 KB Output is correct
43 Correct 316 ms 1260 KB Output is correct
44 Correct 319 ms 1268 KB Output is correct
45 Correct 354 ms 1276 KB Output is correct
46 Correct 361 ms 852 KB Output is correct
47 Correct 348 ms 1100 KB Output is correct
48 Correct 318 ms 1148 KB Output is correct
49 Correct 328 ms 896 KB Output is correct
50 Correct 344 ms 1020 KB Output is correct
51 Correct 311 ms 852 KB Output is correct
52 Correct 386 ms 1312 KB Output is correct
53 Correct 457 ms 1260 KB Output is correct
54 Correct 647 ms 1468 KB Output is correct
55 Correct 645 ms 1600 KB Output is correct
56 Correct 485 ms 1380 KB Output is correct
57 Correct 632 ms 1740 KB Output is correct
58 Correct 649 ms 1476 KB Output is correct
59 Correct 641 ms 1468 KB Output is correct
60 Correct 607 ms 980 KB Output is correct
61 Correct 639 ms 1600 KB Output is correct
62 Correct 523 ms 1544 KB Output is correct
63 Correct 536 ms 1616 KB Output is correct
64 Correct 530 ms 1532 KB Output is correct
65 Correct 510 ms 1020 KB Output is correct
66 Correct 486 ms 1004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 7 ms 456 KB Output is correct
11 Correct 5 ms 468 KB Output is correct
12 Correct 5 ms 480 KB Output is correct
13 Correct 4 ms 340 KB Output is correct
14 Correct 5 ms 468 KB Output is correct
15 Correct 7 ms 340 KB Output is correct
16 Correct 6 ms 340 KB Output is correct
17 Correct 3 ms 340 KB Output is correct
18 Correct 4 ms 340 KB Output is correct
19 Correct 4 ms 340 KB Output is correct
20 Correct 5 ms 468 KB Output is correct
21 Correct 23 ms 524 KB Output is correct
22 Correct 29 ms 560 KB Output is correct
23 Correct 14 ms 504 KB Output is correct
24 Correct 46 ms 584 KB Output is correct
25 Correct 54 ms 596 KB Output is correct
26 Correct 52 ms 604 KB Output is correct
27 Correct 52 ms 592 KB Output is correct
28 Correct 60 ms 600 KB Output is correct
29 Correct 52 ms 596 KB Output is correct
30 Correct 51 ms 596 KB Output is correct
31 Correct 52 ms 596 KB Output is correct
32 Correct 56 ms 600 KB Output is correct
33 Correct 56 ms 596 KB Output is correct
34 Correct 54 ms 596 KB Output is correct
35 Correct 54 ms 596 KB Output is correct
36 Correct 55 ms 608 KB Output is correct
37 Correct 206 ms 920 KB Output is correct
38 Correct 205 ms 924 KB Output is correct
39 Correct 322 ms 852 KB Output is correct
40 Correct 380 ms 1052 KB Output is correct
41 Correct 372 ms 936 KB Output is correct
42 Correct 314 ms 1020 KB Output is correct
43 Correct 316 ms 1260 KB Output is correct
44 Correct 319 ms 1268 KB Output is correct
45 Correct 354 ms 1276 KB Output is correct
46 Correct 361 ms 852 KB Output is correct
47 Correct 348 ms 1100 KB Output is correct
48 Correct 318 ms 1148 KB Output is correct
49 Correct 328 ms 896 KB Output is correct
50 Correct 344 ms 1020 KB Output is correct
51 Correct 311 ms 852 KB Output is correct
52 Correct 386 ms 1312 KB Output is correct
53 Correct 457 ms 1260 KB Output is correct
54 Correct 647 ms 1468 KB Output is correct
55 Correct 645 ms 1600 KB Output is correct
56 Correct 485 ms 1380 KB Output is correct
57 Correct 632 ms 1740 KB Output is correct
58 Correct 649 ms 1476 KB Output is correct
59 Correct 641 ms 1468 KB Output is correct
60 Correct 607 ms 980 KB Output is correct
61 Correct 639 ms 1600 KB Output is correct
62 Correct 523 ms 1544 KB Output is correct
63 Correct 536 ms 1616 KB Output is correct
64 Correct 530 ms 1532 KB Output is correct
65 Correct 510 ms 1020 KB Output is correct
66 Correct 486 ms 1004 KB Output is correct
67 Correct 841 ms 1696 KB Output is correct
68 Correct 3 ms 340 KB Output is correct
69 Execution timed out 1080 ms 1364 KB Time limit exceeded
70 Halted 0 ms 0 KB -