Submission #342908

# Submission time Handle Problem Language Result Execution time Memory
342908 2021-01-03T08:01:31 Z vonatlus Bootfall (IZhO17_bootfall) C++14
0 / 100
1 ms 620 KB
/// vonat1us 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7; 
const int INF = 1e9 + 1e2;
  
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void fin() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

const int N = 1e5+10;
const int B = 1e5+3e4;

bitset<B> dp;
   
int cnt[B];

void ma1n() {
    int n;
    cin >> n;
    vector<int> a(n);
    int s = 0;
    for (int& x : a) {
        cin >> x, s += x;
    }
    if (s&1) cout << 0, exit(0);
    for (int i = -1; i < n; ++i) {
        dp.reset();
        dp.set(0, 1);
        for (int j = 0; j < n; ++j) {
            if (i == j) continue;
            dp |= dp<<a[j];
        }
        if (i == -1) {
            if (!dp[s/2]) {
                cout << 0, exit(0);
            }
            continue;    
        }
        for (int b = 0; b <= s; ++b) {
            if (dp[b]) {
                cnt[(s-a[i])-b-b]++;
            }
        }
    }
    vector<int> ans;
    for (int i = 0; i <= s; ++i) {
        if (cnt[i] == n) {
            ans.pb(i);
        }
    }
    cout << sz(ans) << "\n";
    for (int x : ans) cout << x << " ";
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), fin();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -