이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |