#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define pb push_back
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ii = pair<int,int>;
using iii = tuple<int,int,int>;
const int inf = 2e9+1;
const int mod = 1e9+7;
const int maxn = 1e4+1;
template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }
int a[maxn], where[maxn], ans[maxn][101], resp[100];
int main(){_
int n,l;cin>>n>>l;
for(int i=1;i<=n;++i)cin>>a[i];
int q;cin>>q;
vector<ii>qu(q);
for(int i=0;i<q;++i)cin>>qu[i].first, qu[i].second = i;
sort(all(qu));
int i = 0;
for(int j=0;j<q;++j)
while(i!=qu[j].first)++i, where[i] = j;
while(i!=l)++i, where[i] = q+1;
for(int i=1;i<=n-l;++i){//distance from two strings
int x = 1, y = 1 + i, cur = 0;
for(int j=0;j<l;++j)cur += (a[j+1]!=a[i+j+1]);
ans[x++][where[cur]]++, ans[y++][where[cur]]++;
while(y+l-1<=n){
cur += (a[x+l-1]!=a[y+l-1])-(a[x-1]!=a[y-1]);
ans[x++][where[cur]]++, ans[y++][where[cur]]++;
}
}
for(int i=1;i<=n-l+1;++i)
for(int j=1;j<q;++j)
ans[i][j] += ans[i][j-1];
sort(all(qu), [&](ii x,ii y){return x.second<y.second;});
for(auto [a,b]:qu)
for(int i=1;i<=n-l+1;++i)cout<<ans[i][where[a]]<<" \n"[i==n-l+1];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
452 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
452 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
19 ms |
1144 KB |
Output is correct |
14 |
Correct |
10 ms |
852 KB |
Output is correct |
15 |
Correct |
9 ms |
852 KB |
Output is correct |
16 |
Correct |
16 ms |
1068 KB |
Output is correct |
17 |
Correct |
16 ms |
980 KB |
Output is correct |
18 |
Correct |
14 ms |
980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
423 ms |
4328 KB |
Output is correct |
2 |
Correct |
415 ms |
4316 KB |
Output is correct |
3 |
Correct |
380 ms |
4316 KB |
Output is correct |
4 |
Correct |
392 ms |
4324 KB |
Output is correct |
5 |
Correct |
108 ms |
2460 KB |
Output is correct |
6 |
Correct |
360 ms |
4128 KB |
Output is correct |
7 |
Correct |
119 ms |
2460 KB |
Output is correct |
8 |
Correct |
218 ms |
3228 KB |
Output is correct |
9 |
Correct |
374 ms |
4268 KB |
Output is correct |
10 |
Correct |
390 ms |
4320 KB |
Output is correct |
11 |
Correct |
18 ms |
1108 KB |
Output is correct |
12 |
Correct |
208 ms |
3196 KB |
Output is correct |
13 |
Correct |
166 ms |
2800 KB |
Output is correct |
14 |
Correct |
156 ms |
2804 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
423 ms |
4328 KB |
Output is correct |
2 |
Correct |
415 ms |
4316 KB |
Output is correct |
3 |
Correct |
380 ms |
4316 KB |
Output is correct |
4 |
Correct |
392 ms |
4324 KB |
Output is correct |
5 |
Correct |
108 ms |
2460 KB |
Output is correct |
6 |
Correct |
360 ms |
4128 KB |
Output is correct |
7 |
Correct |
119 ms |
2460 KB |
Output is correct |
8 |
Correct |
218 ms |
3228 KB |
Output is correct |
9 |
Correct |
374 ms |
4268 KB |
Output is correct |
10 |
Correct |
390 ms |
4320 KB |
Output is correct |
11 |
Correct |
18 ms |
1108 KB |
Output is correct |
12 |
Correct |
208 ms |
3196 KB |
Output is correct |
13 |
Correct |
166 ms |
2800 KB |
Output is correct |
14 |
Correct |
156 ms |
2804 KB |
Output is correct |
15 |
Correct |
369 ms |
4200 KB |
Output is correct |
16 |
Correct |
339 ms |
4020 KB |
Output is correct |
17 |
Correct |
403 ms |
4396 KB |
Output is correct |
18 |
Correct |
417 ms |
4360 KB |
Output is correct |
19 |
Correct |
392 ms |
4364 KB |
Output is correct |
20 |
Correct |
396 ms |
4364 KB |
Output is correct |
21 |
Correct |
392 ms |
4380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
296 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
452 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
19 ms |
1144 KB |
Output is correct |
14 |
Correct |
10 ms |
852 KB |
Output is correct |
15 |
Correct |
9 ms |
852 KB |
Output is correct |
16 |
Correct |
16 ms |
1068 KB |
Output is correct |
17 |
Correct |
16 ms |
980 KB |
Output is correct |
18 |
Correct |
14 ms |
980 KB |
Output is correct |
19 |
Correct |
423 ms |
4328 KB |
Output is correct |
20 |
Correct |
415 ms |
4316 KB |
Output is correct |
21 |
Correct |
380 ms |
4316 KB |
Output is correct |
22 |
Correct |
392 ms |
4324 KB |
Output is correct |
23 |
Correct |
108 ms |
2460 KB |
Output is correct |
24 |
Correct |
360 ms |
4128 KB |
Output is correct |
25 |
Correct |
119 ms |
2460 KB |
Output is correct |
26 |
Correct |
218 ms |
3228 KB |
Output is correct |
27 |
Correct |
374 ms |
4268 KB |
Output is correct |
28 |
Correct |
390 ms |
4320 KB |
Output is correct |
29 |
Correct |
18 ms |
1108 KB |
Output is correct |
30 |
Correct |
208 ms |
3196 KB |
Output is correct |
31 |
Correct |
166 ms |
2800 KB |
Output is correct |
32 |
Correct |
156 ms |
2804 KB |
Output is correct |
33 |
Correct |
369 ms |
4200 KB |
Output is correct |
34 |
Correct |
339 ms |
4020 KB |
Output is correct |
35 |
Correct |
403 ms |
4396 KB |
Output is correct |
36 |
Correct |
417 ms |
4360 KB |
Output is correct |
37 |
Correct |
392 ms |
4364 KB |
Output is correct |
38 |
Correct |
396 ms |
4364 KB |
Output is correct |
39 |
Correct |
392 ms |
4380 KB |
Output is correct |
40 |
Correct |
457 ms |
5052 KB |
Output is correct |
41 |
Correct |
14 ms |
900 KB |
Output is correct |
42 |
Correct |
414 ms |
5060 KB |
Output is correct |
43 |
Correct |
384 ms |
4616 KB |
Output is correct |
44 |
Correct |
402 ms |
4744 KB |
Output is correct |
45 |
Correct |
515 ms |
8140 KB |
Output is correct |
46 |
Incorrect |
19 ms |
1284 KB |
Output isn't correct |
47 |
Halted |
0 ms |
0 KB |
- |