# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
736406 | study | Lottery (CEOI18_lot) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e4+1;
int a[N], diff[N][N], ans[N][N];
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,l;
cin >> n >> l;
for (int i=0; i<n; ++i){
cin >> a[i];
}
for (int i=1; i<n-l+1; ++i){
for (int j=0; j<l; ++j){
if (a[i+j] != a[j]) diff[0][i]++;
}
ans[0][diff[0][i]]++;
ans[i][diff[0][i]]++;
}
for (int i=1; i<n-l+1; ++i){
for (int j=i+1; j<n-l+1; ++j){
diff[i][j] = diff[i-1][j-1]-(a[i-1] != a[j-1])+(a[i+l-1] != a[j+l-1]);
ans[i][diff[i][j]]++;
ans[j][diff[i][j]]++;
}
}
for (int i=0; i<n; ++i){
for (int j=1; j<=l; ++j){
ans[i][j] += ans[i][j-1];
}
}
int q;
cin >> q;
while (q--){
int k;
cin >> k;
for (int i=0; i<n-l+1; ++i) cout << ans[i][k] << ' ';
cout << '\n';
}
return 0;
}