Submission #746576

# Submission time Handle Problem Language Result Execution time Memory
746576 2023-05-22T20:54:17 Z pascal Kpart (eJOI21_kpart) C++14
10 / 100
116 ms 296 KB
#include <bits/stdc++.h>
using namespace std;

template <int MOD>
void compute(int N, const int A[], int out[])
{
    bitset<MOD> S;

    for (int deb = 0; deb < N; deb++)
    {
        bitset<1024> S;
        S[0] = true;
        int somme = 0;
        for (int fin = deb; fin < N; fin++)
        {
            somme += A[fin];
            S = S | (S << (A[fin] % MOD) | S >> (MOD - (A[fin] % MOD)));
            if (somme % 2 == 1 || !S[(somme / 2) % 1024])
                out[fin - deb] = 1;
        }
    }
}

int main()
{
    int T;
    cin >> T;
    for (int i = 0; i < T; i++)
    {
        int N;
        cin >> N;
        int A[N];
        for (int i = 0; i < N; i++)
        {
            cin >> A[i];
        }
        int out[N] = {0};
        compute<1024>(N, A, out);
        compute<1023>(N, A, out);
        compute<1021>(N, A, out);
        /*
                for (int deb = 0; deb < N; deb++)
                {
                    bitset<1024> S;
                    S[0] = true;
                    int somme = 0;
                    for (int fin = deb; fin < N; fin++)
                    {
                        somme += A[fin];
                        S = S | (S << A[fin] | S >> (1024 - (A[fin] % 1024)));
                        if (somme % 2 == 1 || !S[(somme / 2) % 1024])
                            out[fin - deb] = 1;
                    }
                }*/
        int nb = 0;
        for (int i = 0; i < N; i++)
            if (out[i] == 0)
                nb++;
        cout << nb;
        for (int i = 0; i < N; i++)
            if (out[i] == 0)
                cout << " " << i + 1;
        cout << endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 116 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -