#include <bits/stdc++.h>
using namespace std;
const int N = 1e4, Q = 100;
int a[1 + N], ans[1 + Q + 1][1 + N + 1], match[1 + N], nrm[1 + N + 1], k[1 + N];
int main () {
int n, l;
ios::sync_with_stdio (false);
cin.tie (0); cout.tie (0);
cin >> n >> l;
for (int i = 1; i <= n; i++)
cin >> a[i];
int q;
cin >> q;
for (int i = 1; i <= q; i++) {
cin >> k[i];
nrm[k[i]] = 1;
}
for (int i = l; i >= 0; i--)
nrm[i] += nrm[i + 1];
for (int i = 0; i <= l; i++)
nrm[i] = q - nrm[i] + 1;
for (int d = 1; d + l <= n; d++) {
memset (match, 0, sizeof match);
for (int i = 1; i + d <= n; i++)
if (a[i] == a[i + d])
match[i] = 0;
else
match[i] = 1;
for (int i = 1; i + d <= n; i++)
match[i] += match[i - 1];
for (int i = 1; i + l - 1 <= n - d; i++) {
ans[ nrm[ match[i + l - 1] - match[i - 1] ] ][i]++;
ans[ nrm[ match[i + l - 1] - match[i - 1] ] ][i + d]++;
}
}
for (int i = 1; i <= q; i++)
for (int j = 1; j <= n - l + 1; j++)
ans[i][j] += ans[i - 1][j];
for (int i = 1; i <= q; i++) {
for (int j = 1; j <= n - l + 1; j++)
cout << ans[nrm[k[i]]][j] << " ";
cout << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
9 |
Correct |
3 ms |
504 KB |
Output is correct |
10 |
Correct |
4 ms |
632 KB |
Output is correct |
11 |
Correct |
4 ms |
504 KB |
Output is correct |
12 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
9 |
Correct |
3 ms |
504 KB |
Output is correct |
10 |
Correct |
4 ms |
632 KB |
Output is correct |
11 |
Correct |
4 ms |
504 KB |
Output is correct |
12 |
Correct |
3 ms |
504 KB |
Output is correct |
13 |
Correct |
30 ms |
508 KB |
Output is correct |
14 |
Correct |
20 ms |
632 KB |
Output is correct |
15 |
Correct |
19 ms |
632 KB |
Output is correct |
16 |
Correct |
28 ms |
780 KB |
Output is correct |
17 |
Correct |
26 ms |
760 KB |
Output is correct |
18 |
Correct |
26 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
594 ms |
584 KB |
Output is correct |
2 |
Correct |
595 ms |
576 KB |
Output is correct |
3 |
Correct |
604 ms |
632 KB |
Output is correct |
4 |
Correct |
593 ms |
660 KB |
Output is correct |
5 |
Correct |
242 ms |
632 KB |
Output is correct |
6 |
Correct |
539 ms |
788 KB |
Output is correct |
7 |
Correct |
245 ms |
760 KB |
Output is correct |
8 |
Correct |
369 ms |
632 KB |
Output is correct |
9 |
Correct |
568 ms |
632 KB |
Output is correct |
10 |
Correct |
578 ms |
684 KB |
Output is correct |
11 |
Correct |
35 ms |
504 KB |
Output is correct |
12 |
Correct |
341 ms |
604 KB |
Output is correct |
13 |
Correct |
298 ms |
760 KB |
Output is correct |
14 |
Correct |
320 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
594 ms |
584 KB |
Output is correct |
2 |
Correct |
595 ms |
576 KB |
Output is correct |
3 |
Correct |
604 ms |
632 KB |
Output is correct |
4 |
Correct |
593 ms |
660 KB |
Output is correct |
5 |
Correct |
242 ms |
632 KB |
Output is correct |
6 |
Correct |
539 ms |
788 KB |
Output is correct |
7 |
Correct |
245 ms |
760 KB |
Output is correct |
8 |
Correct |
369 ms |
632 KB |
Output is correct |
9 |
Correct |
568 ms |
632 KB |
Output is correct |
10 |
Correct |
578 ms |
684 KB |
Output is correct |
11 |
Correct |
35 ms |
504 KB |
Output is correct |
12 |
Correct |
341 ms |
604 KB |
Output is correct |
13 |
Correct |
298 ms |
760 KB |
Output is correct |
14 |
Correct |
320 ms |
760 KB |
Output is correct |
15 |
Correct |
569 ms |
632 KB |
Output is correct |
16 |
Correct |
519 ms |
748 KB |
Output is correct |
17 |
Correct |
593 ms |
692 KB |
Output is correct |
18 |
Correct |
585 ms |
764 KB |
Output is correct |
19 |
Correct |
587 ms |
660 KB |
Output is correct |
20 |
Correct |
594 ms |
760 KB |
Output is correct |
21 |
Correct |
609 ms |
632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
504 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
504 KB |
Output is correct |
8 |
Correct |
3 ms |
504 KB |
Output is correct |
9 |
Correct |
3 ms |
504 KB |
Output is correct |
10 |
Correct |
4 ms |
632 KB |
Output is correct |
11 |
Correct |
4 ms |
504 KB |
Output is correct |
12 |
Correct |
3 ms |
504 KB |
Output is correct |
13 |
Correct |
30 ms |
508 KB |
Output is correct |
14 |
Correct |
20 ms |
632 KB |
Output is correct |
15 |
Correct |
19 ms |
632 KB |
Output is correct |
16 |
Correct |
28 ms |
780 KB |
Output is correct |
17 |
Correct |
26 ms |
760 KB |
Output is correct |
18 |
Correct |
26 ms |
760 KB |
Output is correct |
19 |
Correct |
594 ms |
584 KB |
Output is correct |
20 |
Correct |
595 ms |
576 KB |
Output is correct |
21 |
Correct |
604 ms |
632 KB |
Output is correct |
22 |
Correct |
593 ms |
660 KB |
Output is correct |
23 |
Correct |
242 ms |
632 KB |
Output is correct |
24 |
Correct |
539 ms |
788 KB |
Output is correct |
25 |
Correct |
245 ms |
760 KB |
Output is correct |
26 |
Correct |
369 ms |
632 KB |
Output is correct |
27 |
Correct |
568 ms |
632 KB |
Output is correct |
28 |
Correct |
578 ms |
684 KB |
Output is correct |
29 |
Correct |
35 ms |
504 KB |
Output is correct |
30 |
Correct |
341 ms |
604 KB |
Output is correct |
31 |
Correct |
298 ms |
760 KB |
Output is correct |
32 |
Correct |
320 ms |
760 KB |
Output is correct |
33 |
Correct |
569 ms |
632 KB |
Output is correct |
34 |
Correct |
519 ms |
748 KB |
Output is correct |
35 |
Correct |
593 ms |
692 KB |
Output is correct |
36 |
Correct |
585 ms |
764 KB |
Output is correct |
37 |
Correct |
587 ms |
660 KB |
Output is correct |
38 |
Correct |
594 ms |
760 KB |
Output is correct |
39 |
Correct |
609 ms |
632 KB |
Output is correct |
40 |
Correct |
613 ms |
2040 KB |
Output is correct |
41 |
Correct |
44 ms |
760 KB |
Output is correct |
42 |
Correct |
604 ms |
2196 KB |
Output is correct |
43 |
Correct |
575 ms |
2028 KB |
Output is correct |
44 |
Correct |
573 ms |
2040 KB |
Output is correct |
45 |
Correct |
675 ms |
8216 KB |
Output is correct |
46 |
Correct |
51 ms |
1660 KB |
Output is correct |
47 |
Correct |
667 ms |
8400 KB |
Output is correct |
48 |
Correct |
630 ms |
6648 KB |
Output is correct |
49 |
Correct |
632 ms |
7224 KB |
Output is correct |