제출 #615967

#제출 시각아이디문제언어결과실행 시간메모리
615967kidesoKpart (eJOI21_kpart)C++17
10 / 100
2076 ms876 KiB
#include <iostream> #include <queue> #include <algorithm> //#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; dp.push_back(0); int sum = 0; for(int i = k; i < N; ++i){ sum += x[i]; for(int j = dp.size() - 1; j >= 0; --j) dp.push_back(dp[j] + x[i]); sort(dp.begin(), dp.end()); auto it = unique(dp.begin(), dp.end()); dp.resize(distance(dp.begin(), it)); if(sum % 2 == 0 && binary_search(dp.begin(), dp.end(), sum / 2)) ++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...