Submission #1032053

# Submission time Handle Problem Language Result Execution time Memory
1032053 2024-07-23T10:38:55 Z ten_xd Kpart (eJOI21_kpart) C++17
100 / 100
1308 ms 1244 KB
#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);

	rep(i,n)
	{
		for(int j = s; 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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 344 KB Output is correct
2 Correct 19 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 604 KB Output is correct
2 Correct 212 ms 704 KB Output is correct
3 Correct 242 ms 808 KB Output is correct
4 Correct 450 ms 888 KB Output is correct
5 Correct 1029 ms 1128 KB Output is correct
6 Correct 1308 ms 1244 KB Output is correct
7 Correct 1189 ms 1104 KB Output is correct