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 <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <queue>
#include <cstring>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;
#define pii pair<int, int>
#define f first
#define s second
#define ll long long
#define rint int32_t
const int siz = 250001;
rint main() {
cin.tie(0);
// ios_base::sync_with_stdio(0);
int n;
cin >> n;
int raw [n];
for (int i = 0; i < n; i++) cin >> raw[i];
bitset<siz> globalPos(0);
for (int i = 1; i < siz; i++) globalPos[i] = 1;
bitset<siz> check(0);
check[0] = 1;
int checkSum = 0;
for (int i = 0; i < n; i++) {
check |= check<<raw[i];
checkSum += raw[i];
}
if (checkSum%2 == 1 or check[checkSum/2] == 0) globalPos = bitset<siz>(0);
for (int i = 0; i < n; i++) {
bitset<siz> cur(0);
cur[0] = 1;
int locSum = 0;
for (int j = 0; j < n; j++) if (i != j) {
cur |= cur<<raw[j];
locSum += raw[j];
}
bitset<siz> locPos(0);
for (int j = 1; j < siz; j++) {
if ((locSum+j)%2 == 0 and cur[(locSum+j)/2]) locPos[j] = 1;
}
globalPos &= locPos;
}
cout << globalPos.count() << endl;
for (int i = 1; i < siz; i++) if (globalPos[i] == 1) cout << i << " ";
int d = 0;
d++;
}
# | 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... |