Submission #404368

#TimeUsernameProblemLanguageResultExecution timeMemory
404368fvogel499Bootfall (IZhO17_bootfall)C++14
44 / 100
1040 ms580 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 = 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> 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; 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) { even = bitset<siz>(0); uneven = 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]; } if (locSum%2 == 0) { even &= cur>>(locSum/2); uneven &= 0; } else { uneven &= cur>>(locSum/2+1); even &= 0; } } 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...