Submission #978859

# Submission time Handle Problem Language Result Execution time Memory
978859 2024-05-09T19:59:50 Z VMaksimoski008 Kpart (eJOI21_kpart) C++17
0 / 100
188 ms 664 KB
#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n;
    cin >> n;

    vector<int> v(n+1), dp(50005), ans(n+1, 1), res;
       
    for(int i=1; i<=n; i++) {
        cin >> v[i];
        if(v[i] > 50000) continue;
        int sum = 0; dp[v[i]] = i;
        for(int j=50000; j>v[i]; j--) dp[j] = max(dp[j], dp[j-v[i]]);

        for(int j=i; j>=1; j--) {
            sum += v[j];
            if(sum % 2 == 1 || dp[sum/2] < j) ans[i-j+1] = 0;
        }
    }

    for(int i=1; i<=n; i++) if(ans[i]) res.push_back(i);
    cout << res.size() << " ";
    for(int &x : res) cout << x << " ";
    cout << '\n';
}

int main() {
    int t = 1; cin >> t;
    while(t--) solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 49 ms 648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 188 ms 660 KB Output isn't correct
2 Halted 0 ms 0 KB -