This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair < int, int > pii;
typedef vector<int> vi;
typedef vector<long long> vll;
const int N = 250000 / 2 + 1;
const ll mod = 250001;
void solve(){
	int n;
	cin >> n;
	int a[n], x = 0;
	bitset<N> can;
	bool ok = 0, okk = 0;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i] % 2)ok = 1;
		else okk = 1;
		x += a[i];
	}
	bitset<mod> hv;
	hv[0] = 1;
	for(int j = 0; j < n; j++) {
		hv |= (hv << a[j]);
	}
	if(x % 2 || !hv[x / 2] || ok & okk) {
		cout << "0";
		return;
	}
	x -= a[0];
	if(x % 2)ok = 1;
	else ok = 0;
	x += a[0];
	for(int i = 0; i < N; i++) can[i] = 1;
	sort(a, a + n);
	for(int i = 0; i < n; i++) {
		if(i && a[i] == a[i - 1])continue;
		hv.reset();
		hv[0] = 1;
		for(int j = 0; j < n; j++) {
			if(j == i)continue;
			hv |= (hv << a[j]);
		}
		x -= a[i];
		for(int p = can._Find_first(); p != can.size(); p = can._Find_next(p)) {
			int t = p * 2 + ok;
			if(!hv[(x + t) / 2] && ((x + t) / 2 - t < 0 || !hv[(x + t) / 2 - t])) can[p] = 0;
		}
		x += a[i];
	}
	cout << can.count() << '\n';
	for(int p = can._Find_first(); p != can.size(); p = can._Find_next(p)) {
		cout << p * 2 + ok << ' ';
	}	
}
int main() {
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
    int times = 1;
	//cin >> times;
    while(times--)solve();
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |