Submission #891192

# Submission time Handle Problem Language Result Execution time Memory
891192 2023-12-22T11:11:19 Z sleepntsheep Kpart (eJOI21_kpart) C++17
30 / 100
2000 ms 748 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<long long> a(n);
    vector<long long> b(n);
    for (auto &x : a) cin >> x;

    inclusive_scan(ALL(a), begin(b));

    int c[n+1];
    memset(c,0,sizeof c);

    for (int i = 0; i < n; ++i)
    {
        bitset<50001> bb = 1;
        auto sum = 0;
        for (int j = i; j < n; ++j)
        {
            sum += a[j];
            bb = bb | (bb << a[j]);
            int w = j-i+1;
            if (c[w] == n - (w - 1)) continue;
            if (!(sum & 1) && bb[sum / 2])
            {
                if (++c[w] == n - (w - 1))
                {
                    for (int k = w; k <= n; k += w)
                        c[k] = n - (k - 1);
                }
            }
        }
    }

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

    cout << z.size() << '\n';
    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 Correct 6 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 472 KB Output is correct
2 Correct 147 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 633 ms 708 KB Output is correct
2 Correct 1673 ms 608 KB Output is correct
3 Correct 1956 ms 716 KB Output is correct
4 Execution timed out 2019 ms 748 KB Time limit exceeded
5 Halted 0 ms 0 KB -