Submission #434288

# Submission time Handle Problem Language Result Execution time Memory
434288 2021-06-20T21:24:29 Z leaked Bootfall (IZhO17_bootfall) C++14
100 / 100
356 ms 4952 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//    #pragma GCC optimize("-O3")
//    #pragma GCC optimize("no-stack-protector")
//    #pragma GCC optimize("fast-math")
//    #pragma GCC optimize("Ofast")
//    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//    #pragma GCC target("avx,avx2,fma")
//    #pragma GCC optimization ("unroll-loops")
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//using namespace __gnu_pbds;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define vec vector
#define getin freopen("input.txt","r",stdin);
#define getout ofstream cout("output.txt");
#define getfiles getin;getout
#define m_p make_pair
#define f first
#define sz(x) (int)x.size()
#define pw(x) (1LL<<x)
#define pb push_back
#define endl '\n'
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define s second
typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef long double ld;
template<typename T>bool umax(T &a,const T &b)  {return (a<b?a=b,1:0);}
template<typename T>bool umin(T &a,const T &b)  {return (a>b?a=b,1:0);}
const int N=501;
ull dp[N*N];
void add(int x){
    for(int i=N*N-x-1;i>=0;i--){
        dp[i+x]+=dp[i];
    }
}
void del(int x){
    for(int i=x;i<N*N;i++){
        dp[i]-=dp[i-x];
    }
}
signed main(){

    fast_io;
    //ifstream cin("bootfall.in");
   // ofstream cout("bootfall.out");
    int n;
    cin>>n;
    vec<int>a(n);
    int s=0;
    for(auto &z : a)
        cin>>z,s+=z;
    dp[0]=1;
    for(int i=0;i<n;i++)
        add(a[i]);
    vec<int>cand;
    assert(s<N*N);
    for(int i=1;i<N*N;i++)
        cand.pb(i);
    if(s%2){
        cout<<0;
        return 0;
    }
    if(!dp[s/2]){
        cout<<0;
        return 0;
    }
    vec<int>nw;
    for(int i=0;i<n;i++){
        del(a[i]);
        s-=a[i];
        if(i)
            add(a[i-1]),s+=a[i-1];
        nw.clear();
        for(auto &x : cand){
            s+=x;
            int need=s/2;
            need-=x;
//            debug()<<imie(x)imie(need);
            if(need>=0 && dp[need] && s%2==0){
                nw.pb(x);
//                 debug()<<imie(x)imie(need);
            }
            s-=x;
        }
        swap(nw,cand);
//        cout<<endl;
    }
    cout<<sz(cand)<<endl;
    for(auto &z : cand)
        cout<<z<<' ';

    return 0;
}
/*
1
4 2
0110

*/
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3404 KB Output is correct
2 Correct 6 ms 3404 KB Output is correct
3 Correct 4 ms 3404 KB Output is correct
4 Correct 5 ms 3404 KB Output is correct
5 Correct 9 ms 3404 KB Output is correct
6 Correct 7 ms 3404 KB Output is correct
7 Correct 6 ms 3404 KB Output is correct
8 Correct 9 ms 3404 KB Output is correct
9 Correct 8 ms 3392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3404 KB Output is correct
2 Correct 6 ms 3404 KB Output is correct
3 Correct 4 ms 3404 KB Output is correct
4 Correct 5 ms 3404 KB Output is correct
5 Correct 9 ms 3404 KB Output is correct
6 Correct 7 ms 3404 KB Output is correct
7 Correct 6 ms 3404 KB Output is correct
8 Correct 9 ms 3404 KB Output is correct
9 Correct 8 ms 3392 KB Output is correct
10 Correct 17 ms 3388 KB Output is correct
11 Correct 19 ms 3404 KB Output is correct
12 Correct 17 ms 3400 KB Output is correct
13 Correct 16 ms 3432 KB Output is correct
14 Correct 17 ms 3404 KB Output is correct
15 Correct 18 ms 3396 KB Output is correct
16 Correct 19 ms 3404 KB Output is correct
17 Correct 13 ms 3404 KB Output is correct
18 Correct 14 ms 3404 KB Output is correct
19 Correct 16 ms 3404 KB Output is correct
20 Correct 17 ms 3404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3404 KB Output is correct
2 Correct 6 ms 3404 KB Output is correct
3 Correct 4 ms 3404 KB Output is correct
4 Correct 5 ms 3404 KB Output is correct
5 Correct 9 ms 3404 KB Output is correct
6 Correct 7 ms 3404 KB Output is correct
7 Correct 6 ms 3404 KB Output is correct
8 Correct 9 ms 3404 KB Output is correct
9 Correct 8 ms 3392 KB Output is correct
10 Correct 17 ms 3388 KB Output is correct
11 Correct 19 ms 3404 KB Output is correct
12 Correct 17 ms 3400 KB Output is correct
13 Correct 16 ms 3432 KB Output is correct
14 Correct 17 ms 3404 KB Output is correct
15 Correct 18 ms 3396 KB Output is correct
16 Correct 19 ms 3404 KB Output is correct
17 Correct 13 ms 3404 KB Output is correct
18 Correct 14 ms 3404 KB Output is correct
19 Correct 16 ms 3404 KB Output is correct
20 Correct 17 ms 3404 KB Output is correct
21 Correct 35 ms 3396 KB Output is correct
22 Correct 37 ms 3424 KB Output is correct
23 Correct 29 ms 3428 KB Output is correct
24 Correct 46 ms 3404 KB Output is correct
25 Correct 46 ms 3428 KB Output is correct
26 Correct 50 ms 3500 KB Output is correct
27 Correct 47 ms 3432 KB Output is correct
28 Correct 58 ms 3404 KB Output is correct
29 Correct 47 ms 3404 KB Output is correct
30 Correct 47 ms 3432 KB Output is correct
31 Correct 48 ms 3424 KB Output is correct
32 Correct 48 ms 3396 KB Output is correct
33 Correct 46 ms 3432 KB Output is correct
34 Correct 49 ms 3432 KB Output is correct
35 Correct 49 ms 3432 KB Output is correct
36 Correct 49 ms 3404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3404 KB Output is correct
2 Correct 6 ms 3404 KB Output is correct
3 Correct 4 ms 3404 KB Output is correct
4 Correct 5 ms 3404 KB Output is correct
5 Correct 9 ms 3404 KB Output is correct
6 Correct 7 ms 3404 KB Output is correct
7 Correct 6 ms 3404 KB Output is correct
8 Correct 9 ms 3404 KB Output is correct
9 Correct 8 ms 3392 KB Output is correct
10 Correct 17 ms 3388 KB Output is correct
11 Correct 19 ms 3404 KB Output is correct
12 Correct 17 ms 3400 KB Output is correct
13 Correct 16 ms 3432 KB Output is correct
14 Correct 17 ms 3404 KB Output is correct
15 Correct 18 ms 3396 KB Output is correct
16 Correct 19 ms 3404 KB Output is correct
17 Correct 13 ms 3404 KB Output is correct
18 Correct 14 ms 3404 KB Output is correct
19 Correct 16 ms 3404 KB Output is correct
20 Correct 17 ms 3404 KB Output is correct
21 Correct 35 ms 3396 KB Output is correct
22 Correct 37 ms 3424 KB Output is correct
23 Correct 29 ms 3428 KB Output is correct
24 Correct 46 ms 3404 KB Output is correct
25 Correct 46 ms 3428 KB Output is correct
26 Correct 50 ms 3500 KB Output is correct
27 Correct 47 ms 3432 KB Output is correct
28 Correct 58 ms 3404 KB Output is correct
29 Correct 47 ms 3404 KB Output is correct
30 Correct 47 ms 3432 KB Output is correct
31 Correct 48 ms 3424 KB Output is correct
32 Correct 48 ms 3396 KB Output is correct
33 Correct 46 ms 3432 KB Output is correct
34 Correct 49 ms 3432 KB Output is correct
35 Correct 49 ms 3432 KB Output is correct
36 Correct 49 ms 3404 KB Output is correct
37 Correct 95 ms 3428 KB Output is correct
38 Correct 96 ms 3420 KB Output is correct
39 Correct 112 ms 3384 KB Output is correct
40 Correct 134 ms 3468 KB Output is correct
41 Correct 121 ms 3404 KB Output is correct
42 Correct 122 ms 3396 KB Output is correct
43 Correct 125 ms 3616 KB Output is correct
44 Correct 130 ms 3644 KB Output is correct
45 Correct 128 ms 3632 KB Output is correct
46 Correct 127 ms 3420 KB Output is correct
47 Correct 141 ms 3424 KB Output is correct
48 Correct 131 ms 3540 KB Output is correct
49 Correct 119 ms 3428 KB Output is correct
50 Correct 128 ms 3420 KB Output is correct
51 Correct 40 ms 3420 KB Output is correct
52 Correct 142 ms 3664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3404 KB Output is correct
2 Correct 6 ms 3404 KB Output is correct
3 Correct 4 ms 3404 KB Output is correct
4 Correct 5 ms 3404 KB Output is correct
5 Correct 9 ms 3404 KB Output is correct
6 Correct 7 ms 3404 KB Output is correct
7 Correct 6 ms 3404 KB Output is correct
8 Correct 9 ms 3404 KB Output is correct
9 Correct 8 ms 3392 KB Output is correct
10 Correct 17 ms 3388 KB Output is correct
11 Correct 19 ms 3404 KB Output is correct
12 Correct 17 ms 3400 KB Output is correct
13 Correct 16 ms 3432 KB Output is correct
14 Correct 17 ms 3404 KB Output is correct
15 Correct 18 ms 3396 KB Output is correct
16 Correct 19 ms 3404 KB Output is correct
17 Correct 13 ms 3404 KB Output is correct
18 Correct 14 ms 3404 KB Output is correct
19 Correct 16 ms 3404 KB Output is correct
20 Correct 17 ms 3404 KB Output is correct
21 Correct 35 ms 3396 KB Output is correct
22 Correct 37 ms 3424 KB Output is correct
23 Correct 29 ms 3428 KB Output is correct
24 Correct 46 ms 3404 KB Output is correct
25 Correct 46 ms 3428 KB Output is correct
26 Correct 50 ms 3500 KB Output is correct
27 Correct 47 ms 3432 KB Output is correct
28 Correct 58 ms 3404 KB Output is correct
29 Correct 47 ms 3404 KB Output is correct
30 Correct 47 ms 3432 KB Output is correct
31 Correct 48 ms 3424 KB Output is correct
32 Correct 48 ms 3396 KB Output is correct
33 Correct 46 ms 3432 KB Output is correct
34 Correct 49 ms 3432 KB Output is correct
35 Correct 49 ms 3432 KB Output is correct
36 Correct 49 ms 3404 KB Output is correct
37 Correct 95 ms 3428 KB Output is correct
38 Correct 96 ms 3420 KB Output is correct
39 Correct 112 ms 3384 KB Output is correct
40 Correct 134 ms 3468 KB Output is correct
41 Correct 121 ms 3404 KB Output is correct
42 Correct 122 ms 3396 KB Output is correct
43 Correct 125 ms 3616 KB Output is correct
44 Correct 130 ms 3644 KB Output is correct
45 Correct 128 ms 3632 KB Output is correct
46 Correct 127 ms 3420 KB Output is correct
47 Correct 141 ms 3424 KB Output is correct
48 Correct 131 ms 3540 KB Output is correct
49 Correct 119 ms 3428 KB Output is correct
50 Correct 128 ms 3420 KB Output is correct
51 Correct 40 ms 3420 KB Output is correct
52 Correct 142 ms 3664 KB Output is correct
53 Correct 150 ms 3604 KB Output is correct
54 Correct 182 ms 3616 KB Output is correct
55 Correct 197 ms 3928 KB Output is correct
56 Correct 164 ms 3624 KB Output is correct
57 Correct 214 ms 4052 KB Output is correct
58 Correct 182 ms 3672 KB Output is correct
59 Correct 188 ms 4040 KB Output is correct
60 Correct 56 ms 3396 KB Output is correct
61 Correct 200 ms 3924 KB Output is correct
62 Correct 180 ms 4056 KB Output is correct
63 Correct 190 ms 4044 KB Output is correct
64 Correct 178 ms 3976 KB Output is correct
65 Correct 143 ms 3416 KB Output is correct
66 Correct 171 ms 3416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 3404 KB Output is correct
2 Correct 6 ms 3404 KB Output is correct
3 Correct 4 ms 3404 KB Output is correct
4 Correct 5 ms 3404 KB Output is correct
5 Correct 9 ms 3404 KB Output is correct
6 Correct 7 ms 3404 KB Output is correct
7 Correct 6 ms 3404 KB Output is correct
8 Correct 9 ms 3404 KB Output is correct
9 Correct 8 ms 3392 KB Output is correct
10 Correct 17 ms 3388 KB Output is correct
11 Correct 19 ms 3404 KB Output is correct
12 Correct 17 ms 3400 KB Output is correct
13 Correct 16 ms 3432 KB Output is correct
14 Correct 17 ms 3404 KB Output is correct
15 Correct 18 ms 3396 KB Output is correct
16 Correct 19 ms 3404 KB Output is correct
17 Correct 13 ms 3404 KB Output is correct
18 Correct 14 ms 3404 KB Output is correct
19 Correct 16 ms 3404 KB Output is correct
20 Correct 17 ms 3404 KB Output is correct
21 Correct 35 ms 3396 KB Output is correct
22 Correct 37 ms 3424 KB Output is correct
23 Correct 29 ms 3428 KB Output is correct
24 Correct 46 ms 3404 KB Output is correct
25 Correct 46 ms 3428 KB Output is correct
26 Correct 50 ms 3500 KB Output is correct
27 Correct 47 ms 3432 KB Output is correct
28 Correct 58 ms 3404 KB Output is correct
29 Correct 47 ms 3404 KB Output is correct
30 Correct 47 ms 3432 KB Output is correct
31 Correct 48 ms 3424 KB Output is correct
32 Correct 48 ms 3396 KB Output is correct
33 Correct 46 ms 3432 KB Output is correct
34 Correct 49 ms 3432 KB Output is correct
35 Correct 49 ms 3432 KB Output is correct
36 Correct 49 ms 3404 KB Output is correct
37 Correct 95 ms 3428 KB Output is correct
38 Correct 96 ms 3420 KB Output is correct
39 Correct 112 ms 3384 KB Output is correct
40 Correct 134 ms 3468 KB Output is correct
41 Correct 121 ms 3404 KB Output is correct
42 Correct 122 ms 3396 KB Output is correct
43 Correct 125 ms 3616 KB Output is correct
44 Correct 130 ms 3644 KB Output is correct
45 Correct 128 ms 3632 KB Output is correct
46 Correct 127 ms 3420 KB Output is correct
47 Correct 141 ms 3424 KB Output is correct
48 Correct 131 ms 3540 KB Output is correct
49 Correct 119 ms 3428 KB Output is correct
50 Correct 128 ms 3420 KB Output is correct
51 Correct 40 ms 3420 KB Output is correct
52 Correct 142 ms 3664 KB Output is correct
53 Correct 150 ms 3604 KB Output is correct
54 Correct 182 ms 3616 KB Output is correct
55 Correct 197 ms 3928 KB Output is correct
56 Correct 164 ms 3624 KB Output is correct
57 Correct 214 ms 4052 KB Output is correct
58 Correct 182 ms 3672 KB Output is correct
59 Correct 188 ms 4040 KB Output is correct
60 Correct 56 ms 3396 KB Output is correct
61 Correct 200 ms 3924 KB Output is correct
62 Correct 180 ms 4056 KB Output is correct
63 Correct 190 ms 4044 KB Output is correct
64 Correct 178 ms 3976 KB Output is correct
65 Correct 143 ms 3416 KB Output is correct
66 Correct 171 ms 3416 KB Output is correct
67 Correct 227 ms 3800 KB Output is correct
68 Correct 76 ms 3380 KB Output is correct
69 Correct 351 ms 4804 KB Output is correct
70 Correct 348 ms 4056 KB Output is correct
71 Correct 299 ms 4164 KB Output is correct
72 Correct 223 ms 3664 KB Output is correct
73 Correct 238 ms 3656 KB Output is correct
74 Correct 356 ms 4924 KB Output is correct
75 Correct 327 ms 4552 KB Output is correct
76 Correct 354 ms 4840 KB Output is correct
77 Correct 355 ms 4952 KB Output is correct