Submission #1089428

# Submission time Handle Problem Language Result Execution time Memory
1089428 2024-09-16T13:12:22 Z vjudge1 Kpart (eJOI21_kpart) C++17
0 / 100
2 ms 604 KB
#include <bits/stdc++.h>
#include <utility>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define f first
#define s second
#define d(a) (a * (a + 1)) / 2
#define ent '\n'
#define emb emplace_back
typedef double db;
using namespace std;
using namespace __gnu_pbds;
const ll inf = 1e18 + 7;
const int mod = 1e9 + 7;
const int N = 1e3 + 7;
const int INF = 2e9;
void ALLAHU_AKBAR() {
	ios_base::sync_with_stdio (0);
	cin.tie (0);
//	freopen("closing.in","r",stdin);
//	freopen("closing.out","w",stdout);
}
ll binpow (ll a, ll n) {
	if (n == 0)
		return 1;
	if (n % 2 == 1)
		return binpow (a, n - 1) * a;
	else {
		ll b = binpow (a, n / 2);
		return b * b;
	}
}
int n, sm, a[N], gg[N], pr[N];
void solve () {
    cin >> n;
    sm = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pr[i] = pr[i - 1] + a[i];
        sm += a[i];
    }
    set < int > s;
    for (int i = 1; i <= n; i++) s.insert(i), gg[i] = 0;
    s.erase(1);
    for (int i = 1; i <= n; i++) {
        for (int j = sm; j >= a[i]; j--) gg[j] = max(gg[j], gg[j - a[i]]);
        gg[a[i]] = i;
        for (int j = 1; j < i; j++) {
            if ((pr[i] - pr[j - 1]) % 2 || j > gg[(pr[i] - pr[j - 1]) / 2]) s.erase((i - j + 1));
        }
    }
    cout << s.size() << ' ';
    for (auto x : s) cout << x << " ";
    cout << '\n';
}
int main() {
    ALLAHU_AKBAR();
	int IOI = 1;
	cin >> IOI;
	int g = 0;
	while (-- IOI + 1) {
		g++;
		solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -