답안 #891191

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
891191 2023-12-22T11:09:47 Z sleepntsheep Kpart (eJOI21_kpart) C++17
30 / 100
2000 ms 720 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]);
            if (!(sum & 1) && bb[sum / 2])
            {
                ++c[j-i+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;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 348 KB Output is correct
2 Correct 170 ms 500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 728 ms 476 KB Output is correct
2 Correct 1945 ms 720 KB Output is correct
3 Execution timed out 2029 ms 488 KB Time limit exceeded
4 Halted 0 ms 0 KB -