Submission #545919

#TimeUsernameProblemLanguageResultExecution timeMemory
545919rainboyLottery (CEOI18_lot)C11
100 / 100
832 ms8208 KiB
#include <stdio.h>

#define N	10000
#define Q	100

int main() {
	static int aa[N], hh[N + 1], kk[Q], pp[Q + 1][N];
	int n, q, l, h, i, d, k;

	scanf("%d%d", &n, &l);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	scanf("%d", &q);
	for (h = 0; h < q; h++) {
		scanf("%d", &kk[h]);
		if (kk[h] < l)
			hh[kk[h] + 1]++;
	}
	for (k = 1; k <= l; k++)
		hh[k] += hh[k - 1];
	for (d = 1; d < n; d++)
		for (i = 0, k = 0; i + d < n; i++) {
			if (aa[i] != aa[i + d])
				k++;
			if (i >= l - 1) {
				h = hh[k];
				pp[h][i - l + 1]++, pp[h][i + d - l + 1]++;
				if (aa[i - l + 1] != aa[i + d - l + 1])
					k--;
			}
		}
	for (h = 1; h <= q; h++)
		for (i = 0; i + l <= n; i++)
			pp[h][i] += pp[h - 1][i];
	for (h = 0; h < q; h++) {
		for (i = 0; i + l <= n; i++)
			printf("%d ", pp[hh[kk[h]]][i]);
		printf("\n");
	}
	return 0;
}

Compilation message (stderr)

lot.c: In function 'main':
lot.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d%d", &n, &l);
      |  ^~~~~~~~~~~~~~~~~~~~~
lot.c:12:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
lot.c:13:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d", &q);
      |  ^~~~~~~~~~~~~~~
lot.c:15:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d", &kk[h]);
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...