#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(a,b) for(int a = 0; a < (b); ++a)
#define all(t) t.begin(), t.end()
#define pb push_back
const int N = 1005, INF = 2e9+54321;
const ll INF_L = (ll)2e18+54321;
int n,s;
int A[N];
vector<bool> wyn;
vector<int> dp;
void solve()
{
cin >> n;
rep(i,n) cin >> A[i];
wyn.assign(n+1,1), s = 0;
rep(i,n) s += A[i];
dp.assign(s+1,-1);
int at = 0;
rep(i,n)
{
at += A[i];
for(int j = at; j > A[i]; --j) dp[j] = max(dp[j],dp[j-A[i]]);
dp[A[i]] = i;
int su = 0;
for(int j = i; j >= 0; --j)
{
su += A[j];
int len = i-j+1;
if(su % 2 == 1 or dp[su/2] < j) wyn[len] = 0;
}
}
vector<int> re;
for(int i = 1; i <= n; ++i) if(wyn[i]) re.pb(i);
cout << (int)re.size() << ' ';
for(auto x : re) cout << x << ' ';
cout << '\n';
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int T = 1;
cin >> T;
while(T--) solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
348 KB |
Output is correct |
2 |
Correct |
10 ms |
604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
46 ms |
852 KB |
Output is correct |
2 |
Correct |
111 ms |
708 KB |
Output is correct |
3 |
Correct |
119 ms |
740 KB |
Output is correct |
4 |
Correct |
231 ms |
916 KB |
Output is correct |
5 |
Correct |
531 ms |
1108 KB |
Output is correct |
6 |
Correct |
712 ms |
1192 KB |
Output is correct |
7 |
Correct |
680 ms |
1112 KB |
Output is correct |