답안 #537440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
537440 2022-03-15T06:04:56 Z joelau Kpart (eJOI21_kpart) C++14
0 / 100
2000 ms 340 KB
#include <bits/stdc++.h>
using namespace std;

int T,N,A[1005], sum[1005];
bitset<1005> bs;
bitset<100005> dp[2];

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];
        }
        for (int i = 1; i <= N; ++i) bs[i] = 1;
        for (int i = 1; i <= N; ++i) {
            dp[1].reset();
            dp[1][0] = 1;
            for (int j = i; j <= N; ++j) {
                dp[0].reset();
                for (int k = 0; k + A[j] <= 100000; ++k) if (dp[1][k]) dp[0][k] = dp[0][k+A[j]] = 1;
                int total = sum[j] - sum[i-1];
                if (total % 2 == 1 || !dp[0][total/2]) bs[j-i+1] = 0;
                swap(dp[0],dp[1]);
            }
        }
        cout << bs.count();
        for (int i = 1; i <= N; ++i) if (bs[i]) cout << ' ' << i;
        cout << '\n';
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 403 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2072 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2043 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -