Submission #404373

#TimeUsernameProblemLanguageResultExecution timeMemory
404373fvogel499Bootfall (IZhO17_bootfall)C++14
65 / 100
1058 ms716 KiB
#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 = 125001; 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> 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) { cout << 0; return 0; } bitset<siz> even(0); bitset<siz> uneven(0); for (int i = 1; i < siz; i++) even[i] = 1; for (int i = 0; i < siz; i++) uneven[i] = 1; bool evenKilled = false; bool unevenKilled = false; bitset<siz> cur; for (int i = 0; i < n; i++) { cur.reset(); cur[0] = 1; int locSum = 0; for (int j = 0; j < n; j++) if (i != j) { cur |= cur<<raw[j]; locSum += raw[j]; } if (locSum%2 == 0) { even &= cur>>(locSum/2); if (!unevenKilled) { uneven &= 0; unevenKilled = true; } } else { uneven &= cur>>(locSum/2+1); if (!evenKilled) { even &= 0; evenKilled = true; } } } cout << even.count()+uneven.count() << endl; for (int i = 0; i < siz; i++) { if (even[i]) cout << i*2 << " "; if (uneven[i]) cout << i*2+1 << " "; } int d = 0; d++; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...