Submission #891197

# Submission time Handle Problem Language Result Execution time Memory
891197 2023-12-22T11:39:17 Z sleepntsheep Kpart (eJOI21_kpart) C++17
0 / 100
163 ms 664 KB
#include <iostream>
#include <bitset>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <cstring>
#include <numeric>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>
#include <complex>

using namespace std;
#define ALL(x) begin(x), end(x)
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);

void docase()
{
    int n;
    cin >> n;
    vector<int> a(n), dp(50005, -1), c(n+1);
    dp[0] = 0;
    for (auto &x : a) cin >> x;

    for (int sum = 0, i = 0; i < n; ++i)
    {
        sum += a[i];
        for (int j = 50000; j >= a[i]; --j)
        {
            if (dp[j - a[i]] != -1) dp[j] = max(dp[j], max(i + 1, dp[j - a[i]]));
        }
        for (int sub = sum, j = 0; j <= i; ++j)
        {
            if (!(sub & 1) && dp[sub / 2] >= j + 1)
            {
                ++c[i-j+1];
            }
            sub -= a[j];
        }
    }

    vector<int> z;
    for (auto i = 1; i <= n; ++i)
        if (c[i] == n - (i - 1)) z.push_back(i);

    cout << z.size() << ' ';
    for (auto x : z) cout << x << ' ';


    cout << '\n';
}

int main()
{
    ShinLena;
    int T;
    cin >> T;
    while (T--) docase();
    return 0;
}


# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 660 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 37 ms 664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 163 ms 652 KB Output isn't correct
2 Halted 0 ms 0 KB -