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 <bits/stdc++.h>
using namespace std;
#define N 100005
#define Q 105
int n, L, a[N], q, x[Q], maxx;
vector<vector<int>> cnt;
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> n >> L;
for (int i=1; i<=n; i++) cin >> a[i];
cin >> q;
for (int i=1; i<=q; i++) cin >> x[i], maxx=max(maxx, x[i]);
cnt.assign(n-L+5, vector<int>(maxx+5, 0));
for (int i=1; i<=n-L+1; i++) {
for (int j=1; j<=n-L+1; j++) {
if (i==j) continue;
int c = 0;
for (int k=0; k<L; k++) {
if (a[i+k]!=a[j+k]) c++;
}
cnt[i][c]++;
}
}
for (int i=1; i<=n-L+1; i++) {
for (int j=1; j<=L; j++) {
cnt[i][j] += cnt[i][j-1];
}
}
for (int j=1; j<=q; j++) {
for (int i=1; i<=n-L+1; i++) cout << cnt[i][x[j]] << ' ';
cout << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |