Submission #632461

#TimeUsernameProblemLanguageResultExecution timeMemory
632461pragmatistKpart (eJOI21_kpart)C++17
10 / 100
2092 ms340 KiB
#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)1e3 + 7; const int MOD = (int)1e9 + 7; 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; ++i) { dp.reset(); dp[0] = 1; int sum = 0; for(int j = i; j <= i + k - 1; ++j) { sum += a[j]; dp |= dp << a[j]; } if(sum & 1) { ok = 0; break; } if(!dp[sum / 2]) { ok = 0; break; } } 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...