Submission #632457

# Submission time Handle Problem Language Result Execution time Memory
632457 2022-08-20T05:34:25 Z pragmatist Kpart (eJOI21_kpart) C++17
10 / 100
2000 ms 340 KB
#include<bits/stdc++.h>
 
#define ll long long
#define pb push_back
#define sz(v) (int)v.size()
#define nl "\n"
 
using namespace std;
 
const int N = (int)31;
const int M = (int)1e5 + 7; 

int n, a[N];
bitset<M> dp; 

void solve() {
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	vector<int> ans;
	for(int k = 2; k <= n; ++k) {
		bool ok = 1;
		for(int i = 1; i <= n - k + 1 && ok; ++i) {
			dp.reset();
			dp[0] = 1;
			bool cur = 0;
		    int sum = 0;
			for(int j = i; j <= i + k - 1; ++j) {
				sum += a[j];
				dp |= dp << a[j];
			}				
			for(int s = 0; s < M; ++s) {
				if(dp[s] == 1 && sum - s == s) {
					cur = 1;
					break;	
				}
			}
			ok &= cur;
		}          
		if(ok) ans.pb(k);
	}
	cout << sz(ans) << ' ';
	for(auto x : ans) cout << x << ' ';
	cout << nl;
}

int main() {
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);
	cout.tie(0);
	int test;
	cin >> test;
	while(test--) {
		solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 59 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2073 ms 320 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2072 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -