제출 #1161577

#제출 시각아이디문제언어결과실행 시간메모리
1161577strelok1337Kpart (eJOI21_kpart)C++20
0 / 100
263 ms844 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define F first
#define S second
#define IShowSpeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(a) a.begin(),a.end()
const int N=1e3+10;
const ll inf = 1e18 + 1337;
const int mod=1e9+7;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
int a[N],sum[N],ans[N],dp[100010];

int main()
{
	//freopen("bank.in","r",stdin);
	//freopen("bank.out","w",stdout);
	IShowSpeed
	ll tt=1;
	cin>>tt;
	while(tt--)
	{
		ll n;
		cin>>n;
		for(int i=1;i<=n;i++) {
			cin>>a[i];
			sum[i] = sum[i-1] + a[i];
			ans[i] = 1;
		}
		for(int i=0;i<=1e5;i++) dp[i] = 0;
		for(int i=1;i<=n;i++) {
			dp[0] = i;
			for(int j=0;j<=1e5;j++) {
				if(j + a[i] <= (int)1e5) {
					dp[j+a[i]] = max(dp[j],dp[j+a[i]]);
				}
			}
			for(int l=1;l<=i;l++) {
				int x = sum[i] - sum[l-1];
				if(dp[x >> 1] < l || x % 2 == 1) ans[i - l + 1] = 0;
			}
		}
		vector<ll>res;
		for(int i=1;i<=n;i++) {
			if(ans[i]) res.pb(i);
		}
		cout<<res.size()<<" ";
		for(ll x: res) cout<<x<<" ";
		cout<<"\n";
	}
}
/*
1 2 2
2 3 1

*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...