제출 #259888

#제출 시각아이디문제언어결과실행 시간메모리
259888pedroslreyLottery (CEOI18_lot)C++17
80 / 100
3047 ms704 KiB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e4 + 10;

int xs[MAXN];
int ans[MAXN];

int main() {
	int n, l;
	scanf("%d%d", &n, &l);

	for (int i = 0; i < n; ++i)
		scanf("%d", &xs[i]);

	int q;
	scanf("%d", &q);
	while (q--) {
		int k;
		scanf("%d", &k);

		for (int space = 1; space + l - 1 < n; ++space) {
			int diffs = 0;
			for (int i = 0; i < l; ++i)
				if (xs[i] != xs[i + space])
					++diffs;

			if (diffs <= k)
				++ans[0], ++ans[space];

			for (int i = 1; i + space + l - 1 < n; ++i) {
				if (xs[i-1] != xs[i + space - 1])
					--diffs;

				if (xs[i + l - 1] != xs[i + l + space - 1])
					++diffs;

				if (diffs <= k)
					++ans[i], ++ans[i + space];
			}
		}
		for (int i = 0; i < n - l + 1; ++i) {
			printf("%d ", ans[i]);
			ans[i] = 0;
		}
		printf("\n");
	}
}

컴파일 시 표준 에러 (stderr) 메시지

lot.cpp: In function 'int main()':
lot.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &l);
  ~~~~~^~~~~~~~~~~~~~~~
lot.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &xs[i]);
   ~~~~~^~~~~~~~~~~~~~
lot.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &q);
  ~~~~~^~~~~~~~~~
lot.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &k);
   ~~~~~^~~~~~~~~~
#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...