/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = 998244353;
const ll nmax=1000003;
#define int ll
int n, l, a[10010], dif[10010], ans[10010][110], q;//idx, k
int up[10010];
vector<pi> v;//query, idx of query
int32_t main(){
ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
cin>>n>>l;
for(int i=1; i<=n; i++) cin>>a[i];
cin>>q;
for(int i=1; i<=q; i++){
int k;
cin>>k;
v.pb({k, i});
}
sort(v.begin(), v.end());
int pr=-1;
for(pi i : v){
for(int j=pr+1; j<=i.x; j++) up[j]=i.y;
pr=i.x;
}
for(int d=1; d<=n-l; d++){
memset(dif, 0, sizeof dif);
for(int i=1; i<=n-d; i++){
if(a[i]!=a[i+d]) dif[i]++, dif[min(i+l, n+1)]--;
}
for(int i=1; i<=n-d; i++){
dif[i]+=dif[i-1];
//if(d==1) cout<<i-l+1<<" "<<dif[i]<<endl;
if(i>=l && dif[i]<=pr) ans[i-l+1][up[dif[i]]]++, ans[i-l+1+d][up[dif[i]]]++;
}
}
pr=0;
for(int i=1; i<=n-l+1; i++){
pr=0;
for(pi k: v) ans[i][k.y]+=ans[i][pr], pr=k.y;
}
for(int i=1; i<=q; i++){
for(int id=1; id<=n-l+1; id++) cout<<ans[id][i]<<" ";
cout<<"\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
508 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
9 |
Correct |
3 ms |
632 KB |
Output is correct |
10 |
Correct |
4 ms |
764 KB |
Output is correct |
11 |
Correct |
4 ms |
632 KB |
Output is correct |
12 |
Correct |
4 ms |
632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
508 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
9 |
Correct |
3 ms |
632 KB |
Output is correct |
10 |
Correct |
4 ms |
764 KB |
Output is correct |
11 |
Correct |
4 ms |
632 KB |
Output is correct |
12 |
Correct |
4 ms |
632 KB |
Output is correct |
13 |
Correct |
33 ms |
2168 KB |
Output is correct |
14 |
Correct |
23 ms |
1672 KB |
Output is correct |
15 |
Correct |
17 ms |
1656 KB |
Output is correct |
16 |
Correct |
24 ms |
2040 KB |
Output is correct |
17 |
Correct |
21 ms |
1912 KB |
Output is correct |
18 |
Correct |
21 ms |
1912 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
610 ms |
9176 KB |
Output is correct |
2 |
Correct |
527 ms |
9208 KB |
Output is correct |
3 |
Correct |
343 ms |
9200 KB |
Output is correct |
4 |
Correct |
270 ms |
9080 KB |
Output is correct |
5 |
Correct |
183 ms |
4856 KB |
Output is correct |
6 |
Correct |
271 ms |
8660 KB |
Output is correct |
7 |
Correct |
222 ms |
4956 KB |
Output is correct |
8 |
Correct |
337 ms |
6676 KB |
Output is correct |
9 |
Correct |
274 ms |
8956 KB |
Output is correct |
10 |
Correct |
273 ms |
9208 KB |
Output is correct |
11 |
Correct |
30 ms |
2168 KB |
Output is correct |
12 |
Correct |
210 ms |
6520 KB |
Output is correct |
13 |
Correct |
228 ms |
5624 KB |
Output is correct |
14 |
Correct |
223 ms |
5628 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
610 ms |
9176 KB |
Output is correct |
2 |
Correct |
527 ms |
9208 KB |
Output is correct |
3 |
Correct |
343 ms |
9200 KB |
Output is correct |
4 |
Correct |
270 ms |
9080 KB |
Output is correct |
5 |
Correct |
183 ms |
4856 KB |
Output is correct |
6 |
Correct |
271 ms |
8660 KB |
Output is correct |
7 |
Correct |
222 ms |
4956 KB |
Output is correct |
8 |
Correct |
337 ms |
6676 KB |
Output is correct |
9 |
Correct |
274 ms |
8956 KB |
Output is correct |
10 |
Correct |
273 ms |
9208 KB |
Output is correct |
11 |
Correct |
30 ms |
2168 KB |
Output is correct |
12 |
Correct |
210 ms |
6520 KB |
Output is correct |
13 |
Correct |
228 ms |
5624 KB |
Output is correct |
14 |
Correct |
223 ms |
5628 KB |
Output is correct |
15 |
Correct |
516 ms |
9028 KB |
Output is correct |
16 |
Correct |
259 ms |
8312 KB |
Output is correct |
17 |
Correct |
288 ms |
9208 KB |
Output is correct |
18 |
Correct |
266 ms |
9148 KB |
Output is correct |
19 |
Correct |
268 ms |
9204 KB |
Output is correct |
20 |
Correct |
265 ms |
9208 KB |
Output is correct |
21 |
Correct |
270 ms |
9136 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
3 ms |
508 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
3 ms |
508 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
9 |
Correct |
3 ms |
632 KB |
Output is correct |
10 |
Correct |
4 ms |
764 KB |
Output is correct |
11 |
Correct |
4 ms |
632 KB |
Output is correct |
12 |
Correct |
4 ms |
632 KB |
Output is correct |
13 |
Correct |
33 ms |
2168 KB |
Output is correct |
14 |
Correct |
23 ms |
1672 KB |
Output is correct |
15 |
Correct |
17 ms |
1656 KB |
Output is correct |
16 |
Correct |
24 ms |
2040 KB |
Output is correct |
17 |
Correct |
21 ms |
1912 KB |
Output is correct |
18 |
Correct |
21 ms |
1912 KB |
Output is correct |
19 |
Correct |
610 ms |
9176 KB |
Output is correct |
20 |
Correct |
527 ms |
9208 KB |
Output is correct |
21 |
Correct |
343 ms |
9200 KB |
Output is correct |
22 |
Correct |
270 ms |
9080 KB |
Output is correct |
23 |
Correct |
183 ms |
4856 KB |
Output is correct |
24 |
Correct |
271 ms |
8660 KB |
Output is correct |
25 |
Correct |
222 ms |
4956 KB |
Output is correct |
26 |
Correct |
337 ms |
6676 KB |
Output is correct |
27 |
Correct |
274 ms |
8956 KB |
Output is correct |
28 |
Correct |
273 ms |
9208 KB |
Output is correct |
29 |
Correct |
30 ms |
2168 KB |
Output is correct |
30 |
Correct |
210 ms |
6520 KB |
Output is correct |
31 |
Correct |
228 ms |
5624 KB |
Output is correct |
32 |
Correct |
223 ms |
5628 KB |
Output is correct |
33 |
Correct |
516 ms |
9028 KB |
Output is correct |
34 |
Correct |
259 ms |
8312 KB |
Output is correct |
35 |
Correct |
288 ms |
9208 KB |
Output is correct |
36 |
Correct |
266 ms |
9148 KB |
Output is correct |
37 |
Correct |
268 ms |
9204 KB |
Output is correct |
38 |
Correct |
265 ms |
9208 KB |
Output is correct |
39 |
Correct |
270 ms |
9136 KB |
Output is correct |
40 |
Correct |
883 ms |
9872 KB |
Output is correct |
41 |
Correct |
58 ms |
1528 KB |
Output is correct |
42 |
Correct |
325 ms |
9976 KB |
Output is correct |
43 |
Correct |
282 ms |
9208 KB |
Output is correct |
44 |
Correct |
286 ms |
9464 KB |
Output is correct |
45 |
Correct |
966 ms |
12920 KB |
Output is correct |
46 |
Correct |
64 ms |
1784 KB |
Output is correct |
47 |
Correct |
727 ms |
13048 KB |
Output is correct |
48 |
Correct |
350 ms |
10908 KB |
Output is correct |
49 |
Correct |
356 ms |
11572 KB |
Output is correct |