// ~Be name khoda~ //
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define cl clear
#define endll '\n'
const int maxn = 1e6 + 10;
const int maxn5 = 1e4 + 10;
const int maxnt = 1.2e6 + 10;
const int maxn3 = 1e3 + 10;
const int mod = 1e9 + 7;
const ll inf = 2e18;
vector <pair<int, int>> qu;
int a[maxn5], have[maxn5], reff[maxn5], ind[103];
int ans[102][maxn5];
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n, l; cin >> n >> l;
for(int i = 0; i < n; i++) cin >> a[i];
int q; cin >> q;
for(int i = 0; i < q; i++){
int k; cin >> k;
qu.pb({k, i});
}
sort(all(qu));
if(qu.back().fi < l) qu.pb({l, q});
for(int i = 0; i <= l; i++){
reff[i] = lower_bound(all(qu), mp(i, -1)) - qu.begin();
}
for(int i = 1; i < n; i++){
fill(have, have + n + 2, 0);
for(int j = 0; j + i < n; j++) if(a[j] != a[j + i]){
have[max(0, j - l + 1)]++;
have[j + 1]--;
}
int now = 0;
for(int j = 0; j + i + l - 1 < n; j++){
now += have[j];
ans[reff[now]][j]++;
ans[reff[now]][j + i]++;
}
}
ind[qu[0].se] = 0;
for(int i = 1; i < qu.size(); i++){
for(int j = 0; j < n; j++)
ans[i][j] += ans[i - 1][j];
ind[qu[i].se] = i;
}
for(int i = 0; i < q; i++){
for(int j = 0; j + l - 1 < n; j++) cout << ans[ind[i]][j] << ' ';
cout << '\n';
}
}
Compilation message
lot.cpp: In function 'int main()':
lot.cpp:61:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for(int i = 1; i < qu.size(); i++){
| ~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
464 KB |
Output is correct |
12 |
Correct |
2 ms |
460 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
464 KB |
Output is correct |
12 |
Correct |
2 ms |
460 KB |
Output is correct |
13 |
Correct |
19 ms |
340 KB |
Output is correct |
14 |
Correct |
13 ms |
648 KB |
Output is correct |
15 |
Correct |
12 ms |
468 KB |
Output is correct |
16 |
Correct |
17 ms |
728 KB |
Output is correct |
17 |
Correct |
16 ms |
668 KB |
Output is correct |
18 |
Correct |
17 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
607 ms |
600 KB |
Output is correct |
2 |
Correct |
587 ms |
484 KB |
Output is correct |
3 |
Correct |
444 ms |
508 KB |
Output is correct |
4 |
Correct |
379 ms |
564 KB |
Output is correct |
5 |
Correct |
156 ms |
536 KB |
Output is correct |
6 |
Correct |
328 ms |
560 KB |
Output is correct |
7 |
Correct |
140 ms |
532 KB |
Output is correct |
8 |
Correct |
198 ms |
532 KB |
Output is correct |
9 |
Correct |
358 ms |
572 KB |
Output is correct |
10 |
Correct |
370 ms |
564 KB |
Output is correct |
11 |
Correct |
22 ms |
340 KB |
Output is correct |
12 |
Correct |
242 ms |
532 KB |
Output is correct |
13 |
Correct |
211 ms |
532 KB |
Output is correct |
14 |
Correct |
207 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
607 ms |
600 KB |
Output is correct |
2 |
Correct |
587 ms |
484 KB |
Output is correct |
3 |
Correct |
444 ms |
508 KB |
Output is correct |
4 |
Correct |
379 ms |
564 KB |
Output is correct |
5 |
Correct |
156 ms |
536 KB |
Output is correct |
6 |
Correct |
328 ms |
560 KB |
Output is correct |
7 |
Correct |
140 ms |
532 KB |
Output is correct |
8 |
Correct |
198 ms |
532 KB |
Output is correct |
9 |
Correct |
358 ms |
572 KB |
Output is correct |
10 |
Correct |
370 ms |
564 KB |
Output is correct |
11 |
Correct |
22 ms |
340 KB |
Output is correct |
12 |
Correct |
242 ms |
532 KB |
Output is correct |
13 |
Correct |
211 ms |
532 KB |
Output is correct |
14 |
Correct |
207 ms |
468 KB |
Output is correct |
15 |
Correct |
405 ms |
492 KB |
Output is correct |
16 |
Correct |
342 ms |
588 KB |
Output is correct |
17 |
Correct |
395 ms |
568 KB |
Output is correct |
18 |
Correct |
382 ms |
684 KB |
Output is correct |
19 |
Correct |
387 ms |
576 KB |
Output is correct |
20 |
Correct |
353 ms |
588 KB |
Output is correct |
21 |
Correct |
350 ms |
668 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
464 KB |
Output is correct |
12 |
Correct |
2 ms |
460 KB |
Output is correct |
13 |
Correct |
19 ms |
340 KB |
Output is correct |
14 |
Correct |
13 ms |
648 KB |
Output is correct |
15 |
Correct |
12 ms |
468 KB |
Output is correct |
16 |
Correct |
17 ms |
728 KB |
Output is correct |
17 |
Correct |
16 ms |
668 KB |
Output is correct |
18 |
Correct |
17 ms |
596 KB |
Output is correct |
19 |
Correct |
607 ms |
600 KB |
Output is correct |
20 |
Correct |
587 ms |
484 KB |
Output is correct |
21 |
Correct |
444 ms |
508 KB |
Output is correct |
22 |
Correct |
379 ms |
564 KB |
Output is correct |
23 |
Correct |
156 ms |
536 KB |
Output is correct |
24 |
Correct |
328 ms |
560 KB |
Output is correct |
25 |
Correct |
140 ms |
532 KB |
Output is correct |
26 |
Correct |
198 ms |
532 KB |
Output is correct |
27 |
Correct |
358 ms |
572 KB |
Output is correct |
28 |
Correct |
370 ms |
564 KB |
Output is correct |
29 |
Correct |
22 ms |
340 KB |
Output is correct |
30 |
Correct |
242 ms |
532 KB |
Output is correct |
31 |
Correct |
211 ms |
532 KB |
Output is correct |
32 |
Correct |
207 ms |
468 KB |
Output is correct |
33 |
Correct |
405 ms |
492 KB |
Output is correct |
34 |
Correct |
342 ms |
588 KB |
Output is correct |
35 |
Correct |
395 ms |
568 KB |
Output is correct |
36 |
Correct |
382 ms |
684 KB |
Output is correct |
37 |
Correct |
387 ms |
576 KB |
Output is correct |
38 |
Correct |
353 ms |
588 KB |
Output is correct |
39 |
Correct |
350 ms |
668 KB |
Output is correct |
40 |
Correct |
599 ms |
1924 KB |
Output is correct |
41 |
Correct |
133 ms |
1320 KB |
Output is correct |
42 |
Correct |
388 ms |
1924 KB |
Output is correct |
43 |
Correct |
372 ms |
1700 KB |
Output is correct |
44 |
Correct |
365 ms |
1828 KB |
Output is correct |
45 |
Correct |
675 ms |
8140 KB |
Output is correct |
46 |
Correct |
131 ms |
4652 KB |
Output is correct |
47 |
Correct |
407 ms |
8288 KB |
Output is correct |
48 |
Correct |
414 ms |
6568 KB |
Output is correct |
49 |
Correct |
424 ms |
7116 KB |
Output is correct |