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<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define ll long long
using namespace std;
const int N = 1e3 + 10;
int n;
int a[N];
namespace sub2 {
bitset<100010> bs;
int cnt[122];
void solve() {
cin >> n;
for(int i = 1; i <= n; ++ i) cin >> a[i];
for(int i = 1; i <= n; ++ i) cnt[i] = 0;
int res = 0;
for(int i = 1; i <= n; ++ i) {
int s = 0;
bs.reset(); bs.set(0);
for(int j = i; j <= n; ++ j) {
s += a[j];
bs |= bs << a[j];
if(s & 1) continue;
if(bs[s / 2] == true) {
if(++ cnt[j - i + 1] == n - (j - i + 1) + 1) ++ res;
}
}
}
cout << res << ' ';
for(int i = 2; i <= n; ++ i) {
if(cnt[i] == n - i + 1) cout << i << ' ';
}
}
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int t; cin >> t;
while(t-- > 0) {
sub2::solve();
cout << '\n';
}
return (0 ^ 0);
}
/// Code by vuavisao
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |