제출 #537428

#제출 시각아이디문제언어결과실행 시간메모리
537428joelauKpart (eJOI21_kpart)C++14
0 / 100
1344 ms393748 KiB
#include <bits/stdc++.h> using namespace std; int T,N,A[1005], sum[1005], dp[1005][100005]; vector<int> ans; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> T; while (T--) { cin >> N; sum[0] = 0; for (int i = 1; i <= N; ++i) { cin >> A[i]; sum[i] = sum[i-1] + A[i]; } memset(dp,0,sizeof(dp)); dp[0][0] = 1; for (int i = 1; i <= N; ++i) for (int j = 0; A[i]+j <= 100000; ++j) if (dp[i-1][j]) dp[i][j] += dp[i-1][j], dp[i][A[i]+j] += dp[i-1][j]; for (int i = 1; i <= N; ++i) { bool can = true; for (int j = 1; i+j-1 <= N && can; ++j) { int total = sum[i+j-1] - sum[j-1]; if (total % 2 != 0 || dp[i+j-1][total/2] == dp[j-1][total/2]) can = false; } if (can) ans.push_back(i); } cout << ans.size(); for (int x: ans) cout << ' ' << x; cout << '\n'; ans.clear(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...