Submission #434287

# Submission time Handle Problem Language Result Execution time Memory
434287 2021-06-20T21:23:58 Z leaked Bootfall (IZhO17_bootfall) C++14
0 / 100
25 ms 3008 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 Incorrect 25 ms 3008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 3008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 3008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 3008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 3008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 3008 KB Output isn't correct
2 Halted 0 ms 0 KB -