Submission #1109454

#TimeUsernameProblemLanguageResultExecution timeMemory
1109454IrateKpart (eJOI21_kpart)C++17
30 / 100
2061 ms1104 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; cin >> t; while(t--){ int n; cin >> n; vector<int>v(n), res; vector<vector<int>>good(n, vector<int>(n)); for(int i = 0;i < n;++i){ cin >> v[i]; } bitset<100005>dp; for(int i = 0;i < n;++i){ int sum = 0; dp[0] = 1; for(int j = i;j < n;++j){ dp |= (dp << v[j]); sum += v[j]; good[i][j] = (sum % 2 == 0 && dp[sum / 2]); } dp.reset(); } for(int l = 1;l <= n;++l){ bool flag = 1; for(int i = 0;i + l - 1 < n;++i){ flag = (flag && good[i][i + l - 1]); } if(flag)res.push_back(l); } cout << (int)res.size() << " "; for(int i : res){ cout << i << " "; } cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...