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 ll long long
#define pb push_back
const int maxn = 2000; //!!!!!
int n, l, q;
int v[1 + maxn];
short dp[1 + maxn][1 + maxn];
short ans[1 + maxn][1 + maxn];
void solve() {
cin >> n >> l;
for(int i = 1; i <= n; i++) {
cin >> v[i];
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
dp[i][j] = dp[i - 1][j - 1];
if(v[i] != v[j]) {
dp[i][j]++;
}
}
}
for(int i = l; i <= n; i++) {
for(int j = l; j <= n; j++) {
short dist = dp[i][j] - dp[i - l][j - l];
ans[i - l + 1][dist]++;
}
}
for(int i = 1; i <= n - l + 1; i++) {
ans[i][0]--;
for(int j = 1; j <= l; j++) {
ans[i][j] += ans[i][j - 1];
}
}
cin >> q;
for(int qi = 1; qi <= q; qi++) {
short dist;
cin >> dist;
for(int i = 1; i <= n - l + 1; i++) {
cout << ans[i][dist] << " ";
}
cout << "\n";
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
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... |