Submission #602410

#TimeUsernameProblemLanguageResultExecution timeMemory
602410pakhomoveeLottery (CEOI18_lot)C++17
Compilation error
0 ms0 KiB
#include <iostream>

using namespace std;
const int maxn = 10000;
int a[maxn];
int prv[maxn];
int curr[maxn];
int queries[100];
int answer[100][maxn];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, l;
    cin >> n >> l;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> queries[i];
    }
    for (int i = 0; i < n; ++i) {
        prv[i] = (a[0] != a[i]);
    }
    for (int i = 1; i < l; ++i) {
        for (int j = 1; j < n; ++j) {
            curr[j] = prv[j - 1] + (a[i] != a[j]);
        }
        memcpy(prv, curr, maxn * sizeof(int));
    }
    for (int i = 0; i < q; ++i) {
        for (int j = l - 1; j < n; ++j) {
            if (curr[j] <= queries[i]) {
                ++answer[i][l - 1];
            }
        }
    }
    for (int i = l; i < n; ++i) {
        curr[l - 1] = 0;
        for (int p = 0; p < l; ++p) {
            if (a[i - p] != a[l - p - 1]) ++curr[l - 1];
        }
        for (int j = l; j < n; ++j) {
            curr[j] = prv[j - 1] - (a[i - l] != a[j - l]) + (a[i] != a[j]);
        }
        memcpy(prv, curr, maxn * sizeof(int));
        for (int qid = 0; qid < q; ++qid) {
            for (int j = l - 1; j < n; ++j) {
                if (curr[j] <= queries[qid]) {
                    ++answer[qid][i];
                }
            }
        }
    }
    for (int i = 0; i < q; ++i) {
        for (int j = l - 1; j < n; ++j) {
            cout << answer[i][j] - 1 << ' ';
        }
        cout << '\n';
    }
}

Compilation message (stderr)

lot.cpp: In function 'int main()':
lot.cpp:32:9: error: 'memcpy' was not declared in this scope
   32 |         memcpy(prv, curr, maxn * sizeof(int));
      |         ^~~~~~
lot.cpp:2:1: note: 'memcpy' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | 
lot.cpp:49:9: error: 'memcpy' was not declared in this scope
   49 |         memcpy(prv, curr, maxn * sizeof(int));
      |         ^~~~~~
lot.cpp:49:9: note: 'memcpy' is defined in header '<cstring>'; did you forget to '#include <cstring>'?