Submission #535435

# Submission time Handle Problem Language Result Execution time Memory
535435 2022-03-10T09:24:17 Z i_am_noob Bootfall (IZhO17_bootfall) C++17
100 / 100
791 ms 9664 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2")

#define ll long long
#define int ll
#define ull unsigned ll
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define chkmin(a,b) (a=min(a,b))
#define chkmax(a,b) (a=max(a,b))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
//#define inf 1010000000
#define inf 4000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr << x << endl;}
template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr << x << ", "; _do(y...);}
#else
#define bug(...) 777771449
#endif

const int mod=1000000007;
const int maxn=505,maxm=18,maxk=7777714;

//i_am_noob
int n,a[maxn],sum;
bitset<maxn*maxn> bs[maxn];
bool vis[maxn];

void orzck(){
    cin >> n;
    rep(n) cin >> a[i];
    sum=accumulate(a,a+n,0ll);
    bitset<maxn*maxn> b;
    b[0]=1;
    rep(n) b|=b<<a[i];
    if((sum&1)||!b[sum/2]){
        cout << "0\n";
        return;
    }
    rep(n) if((a[0]+a[i])&1){
        cout << "0\n";
        return;
    }
    b.set();
    rep(n) if(!vis[a[i]]){
        bs[i][0]=1;
        rep1(j,n) if(i!=j) bs[i]|=bs[i]<<a[j];
        bs[i]<<=a[i]/2;
        vis[a[i]]=1;
        b&=bs[i];
    }
    vector<int> res;
    rep2(i,1,sum+1) if((i+a[0])%2==0){
        if(b[(sum+i)/2]) res.pb(i);
    }
    cout << sz(res) << "\n";
    for(auto i: res) cout << i << ' ';
    cout << "\n";
}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    orzck();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 420 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 480 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 420 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 480 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 3 ms 728 KB Output is correct
12 Correct 3 ms 728 KB Output is correct
13 Correct 1 ms 420 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 2 ms 596 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 2 ms 596 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 420 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 480 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 3 ms 728 KB Output is correct
12 Correct 3 ms 728 KB Output is correct
13 Correct 1 ms 420 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 2 ms 596 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 2 ms 596 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 15 ms 1492 KB Output is correct
22 Correct 20 ms 1656 KB Output is correct
23 Correct 11 ms 1320 KB Output is correct
24 Correct 30 ms 1768 KB Output is correct
25 Correct 5 ms 668 KB Output is correct
26 Correct 6 ms 644 KB Output is correct
27 Correct 5 ms 596 KB Output is correct
28 Correct 4 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 18 ms 1248 KB Output is correct
32 Correct 30 ms 1868 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 3 ms 468 KB Output is correct
36 Correct 33 ms 2084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 420 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 480 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 3 ms 728 KB Output is correct
12 Correct 3 ms 728 KB Output is correct
13 Correct 1 ms 420 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 2 ms 596 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 2 ms 596 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 15 ms 1492 KB Output is correct
22 Correct 20 ms 1656 KB Output is correct
23 Correct 11 ms 1320 KB Output is correct
24 Correct 30 ms 1768 KB Output is correct
25 Correct 5 ms 668 KB Output is correct
26 Correct 6 ms 644 KB Output is correct
27 Correct 5 ms 596 KB Output is correct
28 Correct 4 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 18 ms 1248 KB Output is correct
32 Correct 30 ms 1868 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 3 ms 468 KB Output is correct
36 Correct 33 ms 2084 KB Output is correct
37 Correct 66 ms 2188 KB Output is correct
38 Correct 68 ms 2260 KB Output is correct
39 Correct 3 ms 340 KB Output is correct
40 Correct 250 ms 5392 KB Output is correct
41 Correct 4 ms 340 KB Output is correct
42 Correct 178 ms 4284 KB Output is correct
43 Correct 43 ms 1692 KB Output is correct
44 Correct 44 ms 1664 KB Output is correct
45 Correct 45 ms 1620 KB Output is correct
46 Correct 236 ms 4748 KB Output is correct
47 Correct 171 ms 4260 KB Output is correct
48 Correct 11 ms 984 KB Output is correct
49 Correct 10 ms 596 KB Output is correct
50 Correct 204 ms 4804 KB Output is correct
51 Correct 2 ms 340 KB Output is correct
52 Correct 24 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 420 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 480 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 3 ms 728 KB Output is correct
12 Correct 3 ms 728 KB Output is correct
13 Correct 1 ms 420 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 2 ms 596 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 2 ms 596 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 15 ms 1492 KB Output is correct
22 Correct 20 ms 1656 KB Output is correct
23 Correct 11 ms 1320 KB Output is correct
24 Correct 30 ms 1768 KB Output is correct
25 Correct 5 ms 668 KB Output is correct
26 Correct 6 ms 644 KB Output is correct
27 Correct 5 ms 596 KB Output is correct
28 Correct 4 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 18 ms 1248 KB Output is correct
32 Correct 30 ms 1868 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 3 ms 468 KB Output is correct
36 Correct 33 ms 2084 KB Output is correct
37 Correct 66 ms 2188 KB Output is correct
38 Correct 68 ms 2260 KB Output is correct
39 Correct 3 ms 340 KB Output is correct
40 Correct 250 ms 5392 KB Output is correct
41 Correct 4 ms 340 KB Output is correct
42 Correct 178 ms 4284 KB Output is correct
43 Correct 43 ms 1692 KB Output is correct
44 Correct 44 ms 1664 KB Output is correct
45 Correct 45 ms 1620 KB Output is correct
46 Correct 236 ms 4748 KB Output is correct
47 Correct 171 ms 4260 KB Output is correct
48 Correct 11 ms 984 KB Output is correct
49 Correct 10 ms 596 KB Output is correct
50 Correct 204 ms 4804 KB Output is correct
51 Correct 2 ms 340 KB Output is correct
52 Correct 24 ms 1236 KB Output is correct
53 Correct 227 ms 4560 KB Output is correct
54 Correct 266 ms 4864 KB Output is correct
55 Correct 36 ms 1648 KB Output is correct
56 Correct 259 ms 5128 KB Output is correct
57 Correct 45 ms 1692 KB Output is correct
58 Correct 398 ms 6636 KB Output is correct
59 Correct 220 ms 4284 KB Output is correct
60 Correct 3 ms 416 KB Output is correct
61 Correct 222 ms 4300 KB Output is correct
62 Correct 110 ms 2824 KB Output is correct
63 Correct 70 ms 2048 KB Output is correct
64 Correct 62 ms 1952 KB Output is correct
65 Correct 18 ms 724 KB Output is correct
66 Correct 71 ms 1692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 420 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 724 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 480 KB Output is correct
8 Correct 2 ms 724 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 3 ms 728 KB Output is correct
12 Correct 3 ms 728 KB Output is correct
13 Correct 1 ms 420 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 3 ms 596 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 2 ms 596 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 2 ms 596 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 15 ms 1492 KB Output is correct
22 Correct 20 ms 1656 KB Output is correct
23 Correct 11 ms 1320 KB Output is correct
24 Correct 30 ms 1768 KB Output is correct
25 Correct 5 ms 668 KB Output is correct
26 Correct 6 ms 644 KB Output is correct
27 Correct 5 ms 596 KB Output is correct
28 Correct 4 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 18 ms 1248 KB Output is correct
32 Correct 30 ms 1868 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 2 ms 344 KB Output is correct
35 Correct 3 ms 468 KB Output is correct
36 Correct 33 ms 2084 KB Output is correct
37 Correct 66 ms 2188 KB Output is correct
38 Correct 68 ms 2260 KB Output is correct
39 Correct 3 ms 340 KB Output is correct
40 Correct 250 ms 5392 KB Output is correct
41 Correct 4 ms 340 KB Output is correct
42 Correct 178 ms 4284 KB Output is correct
43 Correct 43 ms 1692 KB Output is correct
44 Correct 44 ms 1664 KB Output is correct
45 Correct 45 ms 1620 KB Output is correct
46 Correct 236 ms 4748 KB Output is correct
47 Correct 171 ms 4260 KB Output is correct
48 Correct 11 ms 984 KB Output is correct
49 Correct 10 ms 596 KB Output is correct
50 Correct 204 ms 4804 KB Output is correct
51 Correct 2 ms 340 KB Output is correct
52 Correct 24 ms 1236 KB Output is correct
53 Correct 227 ms 4560 KB Output is correct
54 Correct 266 ms 4864 KB Output is correct
55 Correct 36 ms 1648 KB Output is correct
56 Correct 259 ms 5128 KB Output is correct
57 Correct 45 ms 1692 KB Output is correct
58 Correct 398 ms 6636 KB Output is correct
59 Correct 220 ms 4284 KB Output is correct
60 Correct 3 ms 416 KB Output is correct
61 Correct 222 ms 4300 KB Output is correct
62 Correct 110 ms 2824 KB Output is correct
63 Correct 70 ms 2048 KB Output is correct
64 Correct 62 ms 1952 KB Output is correct
65 Correct 18 ms 724 KB Output is correct
66 Correct 71 ms 1692 KB Output is correct
67 Correct 512 ms 8104 KB Output is correct
68 Correct 3 ms 340 KB Output is correct
69 Correct 93 ms 2748 KB Output is correct
70 Correct 791 ms 9664 KB Output is correct
71 Correct 788 ms 9580 KB Output is correct
72 Correct 4 ms 340 KB Output is correct
73 Correct 4 ms 340 KB Output is correct
74 Correct 173 ms 3700 KB Output is correct
75 Correct 462 ms 6620 KB Output is correct
76 Correct 45 ms 2264 KB Output is correct
77 Correct 94 ms 3004 KB Output is correct