Submission #891192

#TimeUsernameProblemLanguageResultExecution timeMemory
891192sleepntsheepKpart (eJOI21_kpart)C++17
30 / 100
2019 ms748 KiB
#include <iostream> #include <bitset> #include <fstream> #include <iomanip> #include <cmath> #include <cassert> #include <cstring> #include <numeric> #include <vector> #include <algorithm> #include <deque> #include <set> #include <utility> #include <array> #include <complex> using namespace std; #define ALL(x) begin(x), end(x) #define ShinLena cin.tie(nullptr)->sync_with_stdio(false); void docase() { int n; cin >> n; vector<long long> a(n); vector<long long> b(n); for (auto &x : a) cin >> x; inclusive_scan(ALL(a), begin(b)); int c[n+1]; memset(c,0,sizeof c); for (int i = 0; i < n; ++i) { bitset<50001> bb = 1; auto sum = 0; for (int j = i; j < n; ++j) { sum += a[j]; bb = bb | (bb << a[j]); int w = j-i+1; if (c[w] == n - (w - 1)) continue; if (!(sum & 1) && bb[sum / 2]) { if (++c[w] == n - (w - 1)) { for (int k = w; k <= n; k += w) c[k] = n - (k - 1); } } } } vector<int> z; for (auto i = 1; i <= n; ++i) if (c[i] == n - (i - 1)) z.push_back(i); cout << z.size() << '\n'; for (auto x : z) cout << x << ' '; cout << '\n'; } int main() { ShinLena; int T; cin >> T; while (T--) docase(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...