Submission #1128242

#TimeUsernameProblemLanguageResultExecution timeMemory
1128242colfpKpart (eJOI21_kpart)C++20
10 / 100
2095 ms452 KiB
#include "bits/stdc++.h" using namespace std; #define ll long long #define ff first #define ss second const int N = 3e5+5; int t, n; int main(){ cin >> t; while(t--) { cin >> n; vector <int> a(n+1); int s = 0; for(int i = 1; i <= n; i++) { cin >> a[i]; s += a[i]; } vector <int> us(n+1,0); for(int i = 1; i <= n; i++) { vector <bool> dp(s+1,0); dp[0] = 1; int s1 = 0; for(int j = i; j <= n; j++) { s1 += a[j]; for(int k = s-a[j]; k >= 0; k--) { if(dp[k] == 1) { dp[k + a[j]] = 1; } } if(dp[s1/2] == 1 and s1 % 2 == 0) { us[(j-i+1)]++; } } s -= a[i]; } int cnt = 0; vector <int> v; for(int i = 1; i <= n; i++) { if(us[i] == n-i+1) { cnt++; v.push_back(i); } } cout << cnt << ' '; for(int i = 0;i < v.size();i++) { cout << v[i] << " "; } cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...