This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <string.h>
#define N 1000
#define S 50000
int max(int a, int b) { return a > b ? a : b; }
int main() {
int t;
scanf("%d", &t);
while (t--) {
static int aa[N], dp[S + 1];
static char good[N + 1];
int n, k, i, j, s, cnt;
scanf("%d", &n);
memset(dp, -1, (S + 1) * sizeof *dp);
memset(good, 1, (n + 1) * sizeof *good);
for (j = 0; j < n; j++) {
scanf("%d", &aa[j]);
for (s = S; s >= aa[j]; s--)
dp[s] = max(dp[s], dp[s - aa[j]]);
dp[aa[j]] = j;
s = 0;
for (i = j; i >= 0; i--) {
s += aa[i];
if (s % 2 != 0 || dp[s / 2] < i)
good[j - i + 1] = 0;
}
}
cnt = 0;
for (k = 1; k <= n; k++)
if (good[k])
cnt++;
printf("%d", cnt);
for (k = 1; k <= n; k++)
if (good[k])
printf(" %d", k);
printf("\n");
}
return 0;
}
Compilation message (stderr)
Main.c: In function 'main':
Main.c:12:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | scanf("%d", &t);
| ^~~~~~~~~~~~~~~
Main.c:18:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
18 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
Main.c:22:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
22 | scanf("%d", &aa[j]);
| ^~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |