#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <bitset>
typedef long long ll;
using namespace std;
const int N = 1e5 + 10;
int a[N], cnt[N];
bitset <N> Used;
void solve() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
cnt[i - 1] = 0;
}
for (int i = 1; i <= n; i++) {
Used.reset();
Used[0] = 1;
int cur = 0;
for (int j = i; j <= n; j++) {
Used |= (Used << a[j]);
cur += a[j];
if (cur % 2 == 0 && Used[cur / 2]) cnt[j - i]++;
}
}
vector <int> ans;
for (int i = 0; i < n; i++) {
if (cnt[i] == n - i) ans.push_back(i + 1);
}
cout << ans.size() << " ";
for (auto it : ans)
cout << it << " ";
cout << "\n";
}
int main() {
int t;
cin >> t;
while (t--)
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
60 ms |
348 KB |
Output is correct |
2 |
Correct |
213 ms |
484 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
948 ms |
344 KB |
Output is correct |
2 |
Execution timed out |
2037 ms |
348 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |