#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 = 4e5 + 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;
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);
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
38 ms |
860 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
485 ms |
1884 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |