#include <bits/stdc++.h>
using namespace std;
vector<int> ar;
vector<array<int, 2>> qu;
int n, len, q;
short a[(int)1e4][101];
short ind[(int)1e4+1];
void calc(int pos){
short l=0, r=pos;
short ans=0;
if(pos+l-1>=n) return;
for(int j=0; j+pos<n; j++){
if(ar[j]!=ar[j+pos]) ans++;
if(j-len>=0){
ans-=(ar[j-len]!=ar[j-len+pos]);
}
// cout<<ans<<"\n";
if(j>=len-1){
if(ind[ans]==q){
l++; r++;
continue;
}
a[l][ind[ans]]++;
a[r][ind[ans]]++;
l++; r++;
}
}
};
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> len;
ar.resize(n);
for(auto &i: ar) cin >> i;
cin >> q;
qu.resize(q);
for(int i=0; i<q; i++){
cin >> qu[i][0];
qu[i][1] = i;
}
sort(qu.begin(), qu.end());
int p=0;
for(int j=0; j<=n; j++){
while(p<q&&qu[p][0]< j) p++;
ind[j]=p;
}
for(int i=1; i<n; i++){
calc(i);
}
vector<short> pos(q);
for(int i=0; i<q; i++){
pos[qu[i][1]]=i;
}
for(int i=0; i<n; i++){
for(int j=1; j<q; j++){
a[i][j] += a[i][j-1];
}
}
for(int j=0; j<q; j++){
for(int i=0; i+len-1<n; i++){
cout<<a[i][pos[j]]<<" ";
}
cout<<"\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
11 ms |
860 KB |
Output is correct |
14 |
Correct |
9 ms |
744 KB |
Output is correct |
15 |
Correct |
5 ms |
860 KB |
Output is correct |
16 |
Correct |
7 ms |
860 KB |
Output is correct |
17 |
Correct |
6 ms |
860 KB |
Output is correct |
18 |
Correct |
7 ms |
908 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
317 ms |
2468 KB |
Output is correct |
2 |
Correct |
305 ms |
2464 KB |
Output is correct |
3 |
Correct |
175 ms |
2472 KB |
Output is correct |
4 |
Correct |
113 ms |
2048 KB |
Output is correct |
5 |
Correct |
108 ms |
348 KB |
Output is correct |
6 |
Correct |
105 ms |
852 KB |
Output is correct |
7 |
Correct |
134 ms |
1484 KB |
Output is correct |
8 |
Correct |
174 ms |
1884 KB |
Output is correct |
9 |
Correct |
126 ms |
2276 KB |
Output is correct |
10 |
Correct |
114 ms |
2320 KB |
Output is correct |
11 |
Correct |
11 ms |
604 KB |
Output is correct |
12 |
Correct |
79 ms |
904 KB |
Output is correct |
13 |
Correct |
96 ms |
496 KB |
Output is correct |
14 |
Correct |
87 ms |
520 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
317 ms |
2468 KB |
Output is correct |
2 |
Correct |
305 ms |
2464 KB |
Output is correct |
3 |
Correct |
175 ms |
2472 KB |
Output is correct |
4 |
Correct |
113 ms |
2048 KB |
Output is correct |
5 |
Correct |
108 ms |
348 KB |
Output is correct |
6 |
Correct |
105 ms |
852 KB |
Output is correct |
7 |
Correct |
134 ms |
1484 KB |
Output is correct |
8 |
Correct |
174 ms |
1884 KB |
Output is correct |
9 |
Correct |
126 ms |
2276 KB |
Output is correct |
10 |
Correct |
114 ms |
2320 KB |
Output is correct |
11 |
Correct |
11 ms |
604 KB |
Output is correct |
12 |
Correct |
79 ms |
904 KB |
Output is correct |
13 |
Correct |
96 ms |
496 KB |
Output is correct |
14 |
Correct |
87 ms |
520 KB |
Output is correct |
15 |
Correct |
239 ms |
2404 KB |
Output is correct |
16 |
Correct |
114 ms |
1184 KB |
Output is correct |
17 |
Correct |
142 ms |
2448 KB |
Output is correct |
18 |
Correct |
152 ms |
1364 KB |
Output is correct |
19 |
Correct |
123 ms |
1488 KB |
Output is correct |
20 |
Correct |
133 ms |
2452 KB |
Output is correct |
21 |
Correct |
106 ms |
2464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
600 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
11 ms |
860 KB |
Output is correct |
14 |
Correct |
9 ms |
744 KB |
Output is correct |
15 |
Correct |
5 ms |
860 KB |
Output is correct |
16 |
Correct |
7 ms |
860 KB |
Output is correct |
17 |
Correct |
6 ms |
860 KB |
Output is correct |
18 |
Correct |
7 ms |
908 KB |
Output is correct |
19 |
Correct |
317 ms |
2468 KB |
Output is correct |
20 |
Correct |
305 ms |
2464 KB |
Output is correct |
21 |
Correct |
175 ms |
2472 KB |
Output is correct |
22 |
Correct |
113 ms |
2048 KB |
Output is correct |
23 |
Correct |
108 ms |
348 KB |
Output is correct |
24 |
Correct |
105 ms |
852 KB |
Output is correct |
25 |
Correct |
134 ms |
1484 KB |
Output is correct |
26 |
Correct |
174 ms |
1884 KB |
Output is correct |
27 |
Correct |
126 ms |
2276 KB |
Output is correct |
28 |
Correct |
114 ms |
2320 KB |
Output is correct |
29 |
Correct |
11 ms |
604 KB |
Output is correct |
30 |
Correct |
79 ms |
904 KB |
Output is correct |
31 |
Correct |
96 ms |
496 KB |
Output is correct |
32 |
Correct |
87 ms |
520 KB |
Output is correct |
33 |
Correct |
239 ms |
2404 KB |
Output is correct |
34 |
Correct |
114 ms |
1184 KB |
Output is correct |
35 |
Correct |
142 ms |
2448 KB |
Output is correct |
36 |
Correct |
152 ms |
1364 KB |
Output is correct |
37 |
Correct |
123 ms |
1488 KB |
Output is correct |
38 |
Correct |
133 ms |
2452 KB |
Output is correct |
39 |
Correct |
106 ms |
2464 KB |
Output is correct |
40 |
Correct |
430 ms |
3220 KB |
Output is correct |
41 |
Correct |
62 ms |
2504 KB |
Output is correct |
42 |
Correct |
169 ms |
3216 KB |
Output is correct |
43 |
Correct |
112 ms |
2756 KB |
Output is correct |
44 |
Correct |
128 ms |
2892 KB |
Output is correct |
45 |
Correct |
438 ms |
6292 KB |
Output is correct |
46 |
Correct |
60 ms |
2760 KB |
Output is correct |
47 |
Correct |
353 ms |
6284 KB |
Output is correct |
48 |
Correct |
155 ms |
4436 KB |
Output is correct |
49 |
Correct |
155 ms |
5200 KB |
Output is correct |