//#pragma GCC optimize("inline,Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,popcnt,avx,abm")
#include <bits/stdc++.h>
#define ll long long
#define int ll
typedef long double ld;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define y0 dfgoert
#define y1 kjsjofd
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod = 1000000007;
const int INF1e9 = 1010101010;
const int INF1e18 = 1010101010101010101;
const ld PI = 3.14159265358979323846264338327950288419716939937510;
int n;
int a[101010];
bitset<1000001> id;
void solve() {
cin >> n;
for (int i = 1; i <= n; i++)cin >> a[i];
id = 0;
vector<int> ans;
for (int k = 1; k <= n; k++) {
id = 0;
id[0] = 1;
bool ok = true;
int sum = 0;
// cout << k << endl;
for (int i = 1; i <= n; i++) {
id |= (id << a[i]);
sum += a[i];
if (i - k >= 1){id &= (id >> a[i - k]);sum -= a[i - k];}
// for (int p = 0; p <= 30; p++)
// cout << id[p];
// cout << endl;
if (i - k >= 0) {
if (sum % 2 != 0){ok = false;break;}
if (!id[sum / 2]){ok = false;break;}
continue;
}
}
// cout << endl;
if (ok)ans.push_back(k);
}
cout << ans.size() << " ";
for (int i : ans)cout << i << " ";
cout << '\n';
}
int32_t main() {
fast
int t = 1;
cin >> t;
for (int id = 1; id <= t; id++) {
// cout << "Case " << id << ": ";
solve();
}
}
/**
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
192 ms |
664 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1565 ms |
676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2078 ms |
672 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |