#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define mem(a,i) memset(a,i,sizeof(a))
#define sz(s) (int)s.size()
#define int ll
// #define int short int
#define y1 yy
#define ppb pop_back
#define lb lower_bound
#define ub upper_bound
#define gcd(a,b) __gcd(a,b)
#define in insert
#define pdd pair<ld,ld>
const int MAX=1e4+10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
mt19937 rng;
int n,l,q;
int a[MAX];
int c[MAX][105];
int ans[105][MAX];
pii k[MAX];
int r[MAX];
void solve(){
cin>>n>>l;
for(int i=1;i<=n;i++){
cin>>a[i];
}
cin>>q;
for(int i=1;i<=q;i++){
cin>>k[i].F;
k[i].S=i;
}
sort(k+1,k+q+1);
int pos=1;
for(int i=1;i<=l;i++){
while(pos+1<=q&&i>k[pos].F){
pos++;
}
if(pos==q&&i>k[pos].F)r[i]=q+1;
else r[i]=pos;
}
for(int dif=1;dif+l<=n;dif++){
int i=1,j=dif+1;
int cnt=0;
for(int k=0;k<l;k++){
if(a[i+k]!=a[j+k]){
cnt++;
}
}
c[i][r[cnt]]++;c[j][r[cnt]]++;
i+=l;j+=l;
while(j<=n){
if(a[i]!=a[j])cnt++;
if(a[i-l]!=a[j-l])cnt--;
c[i-l+1][r[cnt]]++;c[j-l+1][r[cnt]]++;
i++,j++;
}
}
for(int i=1;i<=n-l+1;i++){
for(int j=1;j<=q;j++){
c[i][j]+=c[i][j-1];
ans[k[j].S][i]=c[i][j];
}
}
for(int i=1;i<=q;i++){
for(int j=1;j<=n-l+1;j++){
cout<<ans[i][j]<<" ";
}
cout<<"\n";
}
}
main(){
// freopen("color.in", "r", stdin);
// freopen("color.out", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
// cin>>t;
while(t--){
solve();
}
}
Compilation message
lot.cpp:90:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
90 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
2 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
2 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
8 ms |
4444 KB |
Output is correct |
14 |
Correct |
5 ms |
4444 KB |
Output is correct |
15 |
Correct |
4 ms |
4612 KB |
Output is correct |
16 |
Correct |
7 ms |
4696 KB |
Output is correct |
17 |
Correct |
6 ms |
4668 KB |
Output is correct |
18 |
Correct |
7 ms |
4616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
339 ms |
11096 KB |
Output is correct |
2 |
Correct |
493 ms |
10888 KB |
Output is correct |
3 |
Correct |
177 ms |
10888 KB |
Output is correct |
4 |
Correct |
145 ms |
10832 KB |
Output is correct |
5 |
Correct |
48 ms |
8788 KB |
Output is correct |
6 |
Correct |
139 ms |
10884 KB |
Output is correct |
7 |
Correct |
50 ms |
8784 KB |
Output is correct |
8 |
Correct |
82 ms |
9024 KB |
Output is correct |
9 |
Correct |
145 ms |
10884 KB |
Output is correct |
10 |
Correct |
158 ms |
10836 KB |
Output is correct |
11 |
Correct |
10 ms |
4440 KB |
Output is correct |
12 |
Correct |
77 ms |
8788 KB |
Output is correct |
13 |
Correct |
68 ms |
8788 KB |
Output is correct |
14 |
Correct |
72 ms |
8884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
339 ms |
11096 KB |
Output is correct |
2 |
Correct |
493 ms |
10888 KB |
Output is correct |
3 |
Correct |
177 ms |
10888 KB |
Output is correct |
4 |
Correct |
145 ms |
10832 KB |
Output is correct |
5 |
Correct |
48 ms |
8788 KB |
Output is correct |
6 |
Correct |
139 ms |
10884 KB |
Output is correct |
7 |
Correct |
50 ms |
8784 KB |
Output is correct |
8 |
Correct |
82 ms |
9024 KB |
Output is correct |
9 |
Correct |
145 ms |
10884 KB |
Output is correct |
10 |
Correct |
158 ms |
10836 KB |
Output is correct |
11 |
Correct |
10 ms |
4440 KB |
Output is correct |
12 |
Correct |
77 ms |
8788 KB |
Output is correct |
13 |
Correct |
68 ms |
8788 KB |
Output is correct |
14 |
Correct |
72 ms |
8884 KB |
Output is correct |
15 |
Correct |
196 ms |
10812 KB |
Output is correct |
16 |
Correct |
126 ms |
11088 KB |
Output is correct |
17 |
Correct |
161 ms |
10832 KB |
Output is correct |
18 |
Correct |
148 ms |
10896 KB |
Output is correct |
19 |
Correct |
152 ms |
10836 KB |
Output is correct |
20 |
Correct |
150 ms |
10888 KB |
Output is correct |
21 |
Correct |
150 ms |
10836 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
2 ms |
4444 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4444 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
1 ms |
4444 KB |
Output is correct |
13 |
Correct |
8 ms |
4444 KB |
Output is correct |
14 |
Correct |
5 ms |
4444 KB |
Output is correct |
15 |
Correct |
4 ms |
4612 KB |
Output is correct |
16 |
Correct |
7 ms |
4696 KB |
Output is correct |
17 |
Correct |
6 ms |
4668 KB |
Output is correct |
18 |
Correct |
7 ms |
4616 KB |
Output is correct |
19 |
Correct |
339 ms |
11096 KB |
Output is correct |
20 |
Correct |
493 ms |
10888 KB |
Output is correct |
21 |
Correct |
177 ms |
10888 KB |
Output is correct |
22 |
Correct |
145 ms |
10832 KB |
Output is correct |
23 |
Correct |
48 ms |
8788 KB |
Output is correct |
24 |
Correct |
139 ms |
10884 KB |
Output is correct |
25 |
Correct |
50 ms |
8784 KB |
Output is correct |
26 |
Correct |
82 ms |
9024 KB |
Output is correct |
27 |
Correct |
145 ms |
10884 KB |
Output is correct |
28 |
Correct |
158 ms |
10836 KB |
Output is correct |
29 |
Correct |
10 ms |
4440 KB |
Output is correct |
30 |
Correct |
77 ms |
8788 KB |
Output is correct |
31 |
Correct |
68 ms |
8788 KB |
Output is correct |
32 |
Correct |
72 ms |
8884 KB |
Output is correct |
33 |
Correct |
196 ms |
10812 KB |
Output is correct |
34 |
Correct |
126 ms |
11088 KB |
Output is correct |
35 |
Correct |
161 ms |
10832 KB |
Output is correct |
36 |
Correct |
148 ms |
10896 KB |
Output is correct |
37 |
Correct |
152 ms |
10836 KB |
Output is correct |
38 |
Correct |
150 ms |
10888 KB |
Output is correct |
39 |
Correct |
150 ms |
10836 KB |
Output is correct |
40 |
Correct |
512 ms |
11572 KB |
Output is correct |
41 |
Correct |
9 ms |
4696 KB |
Output is correct |
42 |
Correct |
158 ms |
11584 KB |
Output is correct |
43 |
Correct |
152 ms |
11400 KB |
Output is correct |
44 |
Correct |
150 ms |
11344 KB |
Output is correct |
45 |
Correct |
554 ms |
21080 KB |
Output is correct |
46 |
Correct |
12 ms |
11100 KB |
Output is correct |
47 |
Correct |
203 ms |
20816 KB |
Output is correct |
48 |
Correct |
195 ms |
19084 KB |
Output is correct |
49 |
Correct |
178 ms |
19592 KB |
Output is correct |