# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
754285 | Olympia | Bootfall (IZhO17_bootfall) | C++17 | 1062 ms | 324 KiB |
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 <vector>
#include <iostream>
#include <cassert>
#include <cmath>
#include <map>
#include <bitset>
#include <set>
#include <stack>
using namespace std;
bool okay (vector<int> v) {
int sum = 0;
for (int i: v) {
sum += i;
}
if (sum % 2 == 1) {
return false;
}
bitset<5000> bs;
bs[0] = true;
for (int i: v) {
bs |= (bs << i);
}
return bs[sum/2];
}
vector<int> remove (vector<int> v, int ind) {
vector<int> a;
for (int i = 0; i < v.size(); i++) {
if (i != ind) {
a.push_back(v[i]);
}
}
return a;
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
}
vector<int> ans;
for (int i = 0; i <= 10000; i++) {
v.push_back(i);
bool fine = true;
for (int j = 0; j < v.size(); j++) {
if (!okay(remove(v, j))) {
fine = false;
break;
}
}
if (fine) {
ans.push_back(i);
}
v.pop_back();
}
cout << ans.size() << endl;
for (int i: ans) {
cout << i << ' ';
}
cout << endl;
}
Compilation message (stderr)
# | 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... |