Submission #156166

# Submission time Handle Problem Language Result Execution time Memory
156166 2019-10-04T08:45:44 Z andrew Bootfall (IZhO17_bootfall) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#define fi first
#define se second
#define p_b push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define sset ordered_set
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 500;
const ll M = N * N;
const ll mod = 1e9 + 7;
const ll inf = 3e18;
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());

template <typename T> void vout(T s){cout << s << endl;exit(0);}

ll dp[MAXN], kol[MAXN];

int main(){
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    dp[0] = 1;

    ll n;

    cin >> n;

    vector <ll> a(n + 1);

    for(int i = 1; i <= n; i++)cin >> a[i];

    ll sc = 0;

    vector <ll> pref(n + 1);

    for(int i = 1; i <= n; i++){
        for(int j = pref[i - 1] + a[i]; j >= a[i]; j--)(dp[j] += dp[j - a[i]]) %= mod;
        pref[i] = pref[i - 1] + a[i];
    }

    sc = pref[n];

    if(sc % 2)vout(0);
    if(!dp[sc / 2])vout(0);

    ll S;

    for(int i = 1; i <= n; i++){
        for(int j = a[i]; j <= pref[n]; j++){
            dp[j] -= dp[j - a[i]];
            if(dp[j] < 0)dp[j] += mod;
        }

        for(int j = 1; j <= pref[n]; j++){
            S = sc - a[i] + j;
            if(S % 2 == 0 && dp[S / 2])kol[j]++;
        }

        for(int j = pref[n]; j >= a[i]; j--){
            (dp[j] += dp[j - a[i]]) %= mod;
        }
    }

    vector <ll> ans;

    for(int i = 1; i < MAXN; i++)if(kol[i] == n)ans.p_b(i);

    cout << ans.size() << "\n";

    for(auto i : ans)cout << i << " ";
    cout << "\n";

    return 0;
}

Compilation message

bootfall.cpp:19:17: error: '__gnu_pbds' is not a namespace-name
 using namespace __gnu_pbds;
                 ^~~~~~~~~~
bootfall.cpp:19:27: error: expected namespace-name before ';' token
 using namespace __gnu_pbds;
                           ^