답안 #158037

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
158037 2019-10-14T13:19:04 Z hentai_lover Bootfall (IZhO17_bootfall) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define lft(x) x * 2
#define rgt(x) x * 2 + 1

#define tm hui_pizda
#define ft first
#define sd second
#define pb push_back
#define pf push_front
#define sz size()
#define cnt continue
#define m_p make_pair
#define fr(i, l, r) for(int i = l; i <= r; ++ i)
#define rf(i, r, l) for(int i = r; i >= l; -- i)
#define all(x) x.begin(), x.end()
#pragma GCC optimize(-O3)
#pragma GCC optimize(Ofast)
#pragma GCC optimize("unroll-loops")

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using _set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long int;
typedef long double ld;

typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <pii> vpi;
typedef vector <pll> vpl;

mt19937_64 rnd(time(NULL));

const ll N = 1e6 + 10;
const ll mtrxN = 10;
//const ll oo = 1e18 + 10;
const ll oo = 1e9 + 10;
const ll B = 500;
const ll mod = 1e9 + 7;

struct mtrx{
    ll m[mtrxN][mtrxN] = {};
};
mtrx mtrx_mult(mtrx a, mtrx b){
    mtrx c;
    fr(i, 0, mtrxN - 1){
        fr(j, 0, mtrxN - 1){
            ll sum = 0;
            fr(x, 0, mtrxN - 1){
                sum += a.m[i][x] * b.m[x][j];
                sum %= mod;
            }
            c.m[i][j] = sum;
        }
    }
    return c;
}
mtrx mtrx_pow(mtrx a, ll n){
    mtrx res;
    fr(i, 0, mtrxN - 1)fr(j, 0, mtrxN - 1)res.m[i][j] = a.m[i][j];
    n --;
    while(n){
        if(n&1)res = mtrx_mult(res, a);
        a = mtrx_mult(a, a);
        n >>= 1;
    }
    return res;
}
ll _pow(ll a, ll n){
    ll r = 1;
    while(n){
        if(n&1)r = r * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return r;
}
ll div(ll x, ll y, ll md){
    return x * _pow(y, md - 2) % md;
}

ll a[N];
ll n, NN;

vector <ll> calc(ll x){
    vector <vl> dp;
    dp.resize(n + 1);
    fr(i, 0, n)dp[i].resize(2 * NN + 1);

    dp[0][NN] = 1;
    fr(i, 1, n){
        if(i != x){
            fr(j, 0, 2 * NN){
                if(j + a[i] <= 2 * NN)dp[i][j + a[i]] |= dp[i - 1][j];
                if(j - a[i] >= 0)dp[i][j - a[i]] |= dp[i - 1][j];
            }
        }   else dp[i] = dp[i - 1];
    }
    return dp[n];
}

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //NN = 10;

    NN = 0;
    cin >> n;
    if(n % 2 == 1)return cout << 0, 0;
    fr(i, 1, n)cin >> a[i], NN += a[i];
    vl ans(2 * NN + 1, 1);
    fr(i, 0, n){
        vl now = calc(i);
        if(i == 0){
            if(!now[NN])return cout << 0, 0;
            else cnt;
        }
        bool ok = 0;
        fr(j, 0, 2 * NN){
            ans[j] &= now[j];
            ok |= ans[j];
        }
        if(!ok)return cout << 0, 0;
    }

    set <ll> ra;
    fr(i, 0, 2 * NN)
        if(ans[i])ra.insert(abs(i - NN));

    cout << ra.sz << endl;
    for(auto i : ra)cout << i << ' ';
    cout << endl;

    return 0;
}
/*
*/

Compilation message

bootfall.cpp:18:22: warning: '#pragma GCC optimize' is not a string or number [-Wpragmas]
 #pragma GCC optimize(-O3)
                      ^
bootfall.cpp:19:22: warning: '#pragma GCC optimize' is not a string or number [-Wpragmas]
 #pragma GCC optimize(Ofast)
                      ^~~~~
bootfall.cpp:28:19: error: declaration does not declare anything [-fpermissive]
 typedef long long int;
                   ^~~
bootfall.cpp:31:15: error: 'll' was not declared in this scope
 typedef pair <ll, ll> pll;
               ^~
bootfall.cpp:31:15: note: suggested alternative: 'ld'
 typedef pair <ll, ll> pll;
               ^~
               ld
bootfall.cpp:31:19: error: 'll' was not declared in this scope
 typedef pair <ll, ll> pll;
                   ^~
bootfall.cpp:31:19: note: suggested alternative: 'ld'
 typedef pair <ll, ll> pll;
                   ^~
                   ld
bootfall.cpp:31:21: error: template argument 1 is invalid
 typedef pair <ll, ll> pll;
                     ^
bootfall.cpp:31:21: error: template argument 2 is invalid
bootfall.cpp:34:17: error: 'll' was not declared in this scope
 typedef vector <ll> vl;
                 ^~
bootfall.cpp:34:17: note: suggested alternative: 'pll'
 typedef vector <ll> vl;
                 ^~
                 pll
bootfall.cpp:34:19: error: template argument 1 is invalid
 typedef vector <ll> vl;
                   ^
bootfall.cpp:34:19: error: template argument 2 is invalid
bootfall.cpp:40:7: error: 'll' does not name a type; did you mean 'vl'?
 const ll N = 1e6 + 10;
       ^~
       vl
bootfall.cpp:41:7: error: 'll' does not name a type; did you mean 'vl'?
 const ll mtrxN = 10;
       ^~
       vl
bootfall.cpp:43:7: error: 'll' does not name a type; did you mean 'vl'?
 const ll oo = 1e9 + 10;
       ^~
       vl
bootfall.cpp:44:7: error: 'll' does not name a type; did you mean 'vl'?
 const ll B = 500;
       ^~
       vl
bootfall.cpp:45:7: error: 'll' does not name a type; did you mean 'vl'?
 const ll mod = 1e9 + 7;
       ^~
       vl
bootfall.cpp:48:5: error: 'll' does not name a type; did you mean 'vl'?
     ll m[mtrxN][mtrxN] = {};
     ^~
     vl
bootfall.cpp: In function 'mtrx mtrx_mult(mtrx, mtrx)':
bootfall.cpp:52:14: error: 'mtrxN' was not declared in this scope
     fr(i, 0, mtrxN - 1){
              ^
bootfall.cpp:15:41: note: in definition of macro 'fr'
 #define fr(i, l, r) for(int i = l; i <= r; ++ i)
                                         ^
bootfall.cpp:52:14: note: suggested alternative: 'mtrx'
     fr(i, 0, mtrxN - 1){
              ^
bootfall.cpp:15:41: note: in definition of macro 'fr'
 #define fr(i, l, r) for(int i = l; i <= r; ++ i)
                                         ^
bootfall.cpp:54:13: error: 'll' was not declared in this scope
             ll sum = 0;
             ^~
bootfall.cpp:54:13: note: suggested alternative: 'vl'
             ll sum = 0;
             ^~
             vl
bootfall.cpp:56:17: error: 'sum' was not declared in this scope
                 sum += a.m[i][x] * b.m[x][j];
                 ^~~
bootfall.cpp:56:26: error: 'struct mtrx' has no member named 'm'
                 sum += a.m[i][x] * b.m[x][j];
                          ^
bootfall.cpp:56:38: error: 'struct mtrx' has no member named 'm'
                 sum += a.m[i][x] * b.m[x][j];
                                      ^
bootfall.cpp:57:24: error: 'mod' was not declared in this scope
                 sum %= mod;
                        ^~~
bootfall.cpp:57:24: note: suggested alternative: 'modf'
                 sum %= mod;
                        ^~~
                        modf
bootfall.cpp:59:15: error: 'struct mtrx' has no member named 'm'
             c.m[i][j] = sum;
               ^
bootfall.cpp:59:25: error: 'sum' was not declared in this scope
             c.m[i][j] = sum;
                         ^~~
bootfall.cpp: At global scope:
bootfall.cpp:64:23: error: 'll' has not been declared
 mtrx mtrx_pow(mtrx a, ll n){
                       ^~
bootfall.cpp: In function 'mtrx mtrx_pow(mtrx, int)':
bootfall.cpp:66:14: error: 'mtrxN' was not declared in this scope
     fr(i, 0, mtrxN - 1)fr(j, 0, mtrxN - 1)res.m[i][j] = a.m[i][j];
              ^
bootfall.cpp:15:41: note: in definition of macro 'fr'
 #define fr(i, l, r) for(int i = l; i <= r; ++ i)
                                         ^
bootfall.cpp:66:14: note: suggested alternative: 'mtrx'
     fr(i, 0, mtrxN - 1)fr(j, 0, mtrxN - 1)res.m[i][j] = a.m[i][j];
              ^
bootfall.cpp:15:41: note: in definition of macro 'fr'
 #define fr(i, l, r) for(int i = l; i <= r; ++ i)
                                         ^
bootfall.cpp:66:47: error: 'struct mtrx' has no member named 'm'
     fr(i, 0, mtrxN - 1)fr(j, 0, mtrxN - 1)res.m[i][j] = a.m[i][j];
                                               ^
bootfall.cpp:66:59: error: 'struct mtrx' has no member named 'm'
     fr(i, 0, mtrxN - 1)fr(j, 0, mtrxN - 1)res.m[i][j] = a.m[i][j];
                                                           ^
bootfall.cpp: At global scope:
bootfall.cpp:75:1: error: 'll' does not name a type; did you mean 'vl'?
 ll _pow(ll a, ll n){
 ^~
 vl
bootfall.cpp:84:1: error: 'll' does not name a type; did you mean 'vl'?
 ll div(ll x, ll y, ll md){
 ^~
 vl
bootfall.cpp:88:1: error: 'll' does not name a type; did you mean 'vl'?
 ll a[N];
 ^~
 vl
bootfall.cpp:89:1: error: 'll' does not name a type; did you mean 'vl'?
 ll n, NN;
 ^~
 vl
bootfall.cpp:91:9: error: 'll' was not declared in this scope
 vector <ll> calc(ll x){
         ^~
bootfall.cpp:91:9: note: suggested alternative: 'vl'
 vector <ll> calc(ll x){
         ^~
         vl
bootfall.cpp:91:11: error: template argument 1 is invalid
 vector <ll> calc(ll x){
           ^
bootfall.cpp:91:11: error: template argument 2 is invalid
bootfall.cpp:91:18: error: 'll' was not declared in this scope
 vector <ll> calc(ll x){
                  ^~
bootfall.cpp:91:18: note: suggested alternative: 'vl'
 vector <ll> calc(ll x){
                  ^~
                  vl
bootfall.cpp: In function 'int main()':
bootfall.cpp:112:5: error: 'NN' was not declared in this scope
     NN = 0;
     ^~
bootfall.cpp:112:5: note: suggested alternative: 'NAN'
     NN = 0;
     ^~
     NAN
bootfall.cpp:113:12: error: 'n' was not declared in this scope
     cin >> n;
            ^
bootfall.cpp:113:12: note: suggested alternative: 'yn'
     cin >> n;
            ^
            yn
bootfall.cpp:115:23: error: 'a' was not declared in this scope
     fr(i, 1, n)cin >> a[i], NN += a[i];
                       ^
bootfall.cpp:116:25: error: expression list treated as compound expression in initializer [-fpermissive]
     vl ans(2 * NN + 1, 1);
                         ^
bootfall.cpp:118:24: error: 'calc' cannot be used as a function
         vl now = calc(i);
                        ^
bootfall.cpp:125:18: error: invalid types 'vl {aka int}[int]' for array subscript
             ans[j] &= now[j];
                  ^
bootfall.cpp:125:28: error: invalid types 'vl {aka int}[int]' for array subscript
             ans[j] &= now[j];
                            ^
bootfall.cpp:126:24: error: invalid types 'vl {aka int}[int]' for array subscript
             ok |= ans[j];
                        ^
bootfall.cpp:131:10: error: 'll' was not declared in this scope
     set <ll> ra;
          ^~
bootfall.cpp:131:10: note: suggested alternative: 'vl'
     set <ll> ra;
          ^~
          vl
bootfall.cpp:131:12: error: template argument 1 is invalid
     set <ll> ra;
            ^
bootfall.cpp:131:12: error: template argument 2 is invalid
bootfall.cpp:131:12: error: template argument 3 is invalid
bootfall.cpp:133:17: error: invalid types 'vl {aka int}[int]' for array subscript
         if(ans[i])ra.insert(abs(i - NN));
                 ^
bootfall.cpp:133:22: error: request for member 'insert' in 'ra', which is of non-class type 'int'
         if(ans[i])ra.insert(abs(i - NN));
                      ^~~~~~
bootfall.cpp:12:12: error: request for member 'size' in 'ra', which is of non-class type 'int'
 #define sz size()
            ^
bootfall.cpp:135:16: note: in expansion of macro 'sz'
     cout << ra.sz << endl;
                ^~
bootfall.cpp:136:18: error: 'begin' was not declared in this scope
     for(auto i : ra)cout << i << ' ';
                  ^~
bootfall.cpp:136:18: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from bootfall.cpp:1:
/usr/include/c++/7/valarray:1211:5: note:   'std::begin'
     begin(const valarray<_Tp>& __va)
     ^~~~~
/usr/include/c++/7/valarray:1211:5: note:   'std::begin'
bootfall.cpp:136:18: error: 'end' was not declared in this scope
     for(auto i : ra)cout << i << ' ';
                  ^~
bootfall.cpp:136:18: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from bootfall.cpp:1:
/usr/include/c++/7/valarray:1231:5: note:   'std::end'
     end(const valarray<_Tp>& __va)
     ^~~
/usr/include/c++/7/valarray:1231:5: note:   'std::end'