#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("popcnt")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX=2e5+10,P=1e9+7;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;
const ldb eps=1e-6;
const ldb PI=acos(-1.0);
const int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
template<typename T>
using vvector = vector<vector<T>>;
vvector<short> mmm;
int main() {
speed;
int n,l;
cin>>n>>l;
vector<int> a(n+1);
for (int i=0;i<n;i++) {
cin>>a[i];
}
mmm.resize(n-l+1,vector<short>(l+1));
for (int g=1;g+l<=n;g++) {
short now=0;
for (int i=0;i<l;i++) {
if (a[i]!=a[i+g]) now++;
}
for (int i=0;i+g+l<=n;i++) {
mmm[i][now]++;
mmm[i+g][now]++;
now-=(a[i]!=a[i+g]);
now+=(a[i+l]!=a[i+g+l]);
}
}
for (int i=0;i<=n-l;i++) {
for (int j=1;j<=l;j++) mmm[i][j]+=mmm[i][j-1];
}
int q;
cin>>q;
while (q--) {
int k;
cin>>k;
for (int i=0;i+l<=n;i++) cout<<mmm[i][k]<<" ";
cout<<"\n";
}
return 0;
}
/*
10 10
2 34 545 56 3 3 65 2 7 6
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
508 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
508 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
6 ms |
592 KB |
Output is correct |
14 |
Correct |
9 ms |
2244 KB |
Output is correct |
15 |
Correct |
8 ms |
2128 KB |
Output is correct |
16 |
Correct |
9 ms |
1360 KB |
Output is correct |
17 |
Correct |
8 ms |
1616 KB |
Output is correct |
18 |
Correct |
9 ms |
1616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
132 ms |
1096 KB |
Output is correct |
2 |
Correct |
136 ms |
1056 KB |
Output is correct |
3 |
Correct |
130 ms |
848 KB |
Output is correct |
4 |
Correct |
196 ms |
4688 KB |
Output is correct |
5 |
Runtime error |
179 ms |
49652 KB |
Memory limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
132 ms |
1096 KB |
Output is correct |
2 |
Correct |
136 ms |
1056 KB |
Output is correct |
3 |
Correct |
130 ms |
848 KB |
Output is correct |
4 |
Correct |
196 ms |
4688 KB |
Output is correct |
5 |
Runtime error |
179 ms |
49652 KB |
Memory limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
508 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
1 ms |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
6 ms |
592 KB |
Output is correct |
14 |
Correct |
9 ms |
2244 KB |
Output is correct |
15 |
Correct |
8 ms |
2128 KB |
Output is correct |
16 |
Correct |
9 ms |
1360 KB |
Output is correct |
17 |
Correct |
8 ms |
1616 KB |
Output is correct |
18 |
Correct |
9 ms |
1616 KB |
Output is correct |
19 |
Correct |
132 ms |
1096 KB |
Output is correct |
20 |
Correct |
136 ms |
1056 KB |
Output is correct |
21 |
Correct |
130 ms |
848 KB |
Output is correct |
22 |
Correct |
196 ms |
4688 KB |
Output is correct |
23 |
Runtime error |
179 ms |
49652 KB |
Memory limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |