제출 #320758

#제출 시각아이디문제언어결과실행 시간메모리
320758dolphingarlicLottery (CEOI18_lot)C++14
80 / 100
3097 ms868 KiB
#include <bits/stdc++.h>
using namespace std;

int a[10000], ans[10000];

int main() {
    int n, l, q;
    scanf("%d %d", &n, &l);
    for (int i = 0; i < n; i++) scanf("%d", a + i);
    scanf("%d", &q);
    while (q--) {
        int k;
        scanf("%d", &k);
        for (int dx = l - n; dx <= n - l; dx++) {
            int diff = 0;
            for (int i = 0; i <= n - l; i++) {
                int j = i + dx;
                if (j < 0 || j > n - l) continue;
                if (!i || !j) {
                    for (int p = 0; p < l; p++) diff += (a[i + p] != a[j + p]);
                } else {
                    diff += (a[i + l - 1] != a[j + l - 1]) - (a[i - 1] != a[j - 1]);
                }
                if (diff <= k) ans[i]++;
            }
        }
        for (int i = 0; i <= n - l; i++) printf("%d ", ans[i] - 1);
        printf("\n");
        fill(ans, ans + n - l + 1, 0);
    }
}

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

lot.cpp: In function 'int main()':
lot.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    8 |     scanf("%d %d", &n, &l);
      |     ~~~~~^~~~~~~~~~~~~~~~~
lot.cpp:9:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |     for (int i = 0; i < n; i++) scanf("%d", a + i);
      |                                 ~~~~~^~~~~~~~~~~~~
lot.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
lot.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |         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...