제출 #839596

#제출 시각아이디문제언어결과실행 시간메모리
839596DzadzoKpart (eJOI21_kpart)C++17
30 / 100
2071 ms5096 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define S second
#define F first
#define pii pair<int,int>
#define vi vector <int>
#define vvi vector <vi>
#define vvvi vector <vvi>
#define INF LLONG_MAX
#define MOD 1000000009
#define MAXN 100000
using namespace std;
using namespace __gnu_pbds;
int32_t main() {
	ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
	int t;
	cin>>t;
	while (t--){
		int n;
		cin>>n;
		int a[n+1];
		int p[n+1];
		p[0]=0;
		for (int i=1;i<=n;i++){cin>>a[i];p[i]=p[i-1]+a[i];}
		bitset<100001>b[n];
		for (int i=1;i<n;i++)b[i][0]=1;
		for (int i=1;i<n;i++){
			b[i] |= (b[i]<<a[i]);
		}
		vi ans;
		for (int k=2;k<=n;k++){
			bool check=true;
			for (int i=k;i<=n;i++){
				b[i-k+1] |= (b[i-k+1]<<a[i]);
				if ((p[i]-p[i-k])%2!=0)check=false;else
				if (!b[i-k+1][(p[i]-p[i-k])/2])check=false;
			}
			if (check)ans.pb(k);
		}
		cout<<ans.size();
		for (int x:ans)cout<<" "<<x;
		cout<<"\n";
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...