Submission #615951

#TimeUsernameProblemLanguageResultExecution timeMemory
615951kidesoKpart (eJOI21_kpart)C++17
10 / 100
2066 ms724 KiB
#include <iostream> #include <queue> //#include <fstream> using namespace std; //ifstream F("be.txt"); vector<int> ans, x, s; int N; const int maxN = 1e5; void DP(int k){ vector<int> dp(maxN + 1, 0); dp[0] = 1; int sum = 0; for(int i = k; i < N; ++i){ sum += x[i]; for(int j = maxN - x[i]; j >= 0; --j) if(dp[j] == 1) dp[j + x[i]] = 1; if(sum % 2 == 0 && dp[sum / 2] == 1) ++s[i - k + 1]; } return; } int main(){ int T; cin >> T; while(T--){ ans.clear(); cin >> N; x.assign(N, 0); s.assign(N + 1, 0); for(auto &e : x) cin >> e; for(int i = 0; i < N; ++i) DP(i); for(int i = 1; i <= N; ++i) if(s[i] == N - i + 1) ans.push_back(i); cout << ans.size() << ' '; for(auto e : ans) cout << e << ' '; cout << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...