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>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll,ll>
#define all(x) (x).begin(),(x).end()
void solve() {
int n;
cin >> n;
vi a(n);
int sum=0;
for (int i=0; i<n; i++) {
cin >> a[i];
sum+=a[i];
}
vector<bitset<100001>> sets(n,0);
for (int i=0; i<n; i++) {
sets[i][50000]=1;
sets[i]=(sets[i]<<a[i])|(sets[i]>>a[i]);
}
vi ans;
for (int i=1; i<n; i++) {
bool ok=1;
for (int j=0; j+i<n; j++) {
sets[j]=(sets[j]<<a[j+i])|(sets[j]>>a[j+i]);
if (!sets[j][50000]) {
ok=0;
}
}
if (ok) {
ans.pb(i+1);
}
}
cout << ans.size() << ' ';
for (auto a:ans) {
cout << a << ' ';
}
cout << '\n';
}
int32_t main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
int t;
cin >> t;
while (t--) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |