#include <bits/stdc++.h>
using namespace std;
#define for_(i, s, e) for (int i = s; i < (int) e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'
const int MXN = 1e4;
int freq[MXN+1][MXN+2];
int main() {
#ifdef shiven
freopen("test.in", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, l; cin >> n >> l;
vi nums(n);
for_(i, 0, n) cin >> nums[i];
for_(d, 1, n+1) {
vi temp(n);
for_(j, d, n) if (nums[j] != nums[j-d]) temp[j] += 1;
for_(i, d, n) temp[i] += temp[i-1];
for_(j, d, n-l+1) {
int dist = temp[j+l-1] - (j > 0 ? temp[j-1] : 0);
freq[j][dist] += 1; freq[j-d][dist] += 1;
}
}
for_(i, 0, n) for_(j, 1, n+1) freq[i][j] += freq[i][j-1];
int q; cin >> q;
while (q--) {
int k; cin >> k;
for_(i, 0, n-l+1) cout << freq[i][k] << " ";
cout << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
768 KB |
Output is correct |
3 |
Correct |
1 ms |
768 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
1 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
1920 KB |
Output is correct |
9 |
Correct |
2 ms |
1920 KB |
Output is correct |
10 |
Correct |
2 ms |
1920 KB |
Output is correct |
11 |
Correct |
2 ms |
1920 KB |
Output is correct |
12 |
Correct |
2 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
768 KB |
Output is correct |
3 |
Correct |
1 ms |
768 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
1 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
1920 KB |
Output is correct |
9 |
Correct |
2 ms |
1920 KB |
Output is correct |
10 |
Correct |
2 ms |
1920 KB |
Output is correct |
11 |
Correct |
2 ms |
1920 KB |
Output is correct |
12 |
Correct |
2 ms |
1920 KB |
Output is correct |
13 |
Correct |
63 ms |
24192 KB |
Output is correct |
14 |
Correct |
45 ms |
24184 KB |
Output is correct |
15 |
Correct |
43 ms |
24184 KB |
Output is correct |
16 |
Correct |
59 ms |
24440 KB |
Output is correct |
17 |
Correct |
53 ms |
24184 KB |
Output is correct |
18 |
Correct |
55 ms |
24188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1527 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1527 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
768 KB |
Output is correct |
3 |
Correct |
1 ms |
768 KB |
Output is correct |
4 |
Correct |
1 ms |
768 KB |
Output is correct |
5 |
Correct |
1 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
768 KB |
Output is correct |
7 |
Correct |
1 ms |
768 KB |
Output is correct |
8 |
Correct |
3 ms |
1920 KB |
Output is correct |
9 |
Correct |
2 ms |
1920 KB |
Output is correct |
10 |
Correct |
2 ms |
1920 KB |
Output is correct |
11 |
Correct |
2 ms |
1920 KB |
Output is correct |
12 |
Correct |
2 ms |
1920 KB |
Output is correct |
13 |
Correct |
63 ms |
24192 KB |
Output is correct |
14 |
Correct |
45 ms |
24184 KB |
Output is correct |
15 |
Correct |
43 ms |
24184 KB |
Output is correct |
16 |
Correct |
59 ms |
24440 KB |
Output is correct |
17 |
Correct |
53 ms |
24184 KB |
Output is correct |
18 |
Correct |
55 ms |
24188 KB |
Output is correct |
19 |
Runtime error |
1527 ms |
65540 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
20 |
Halted |
0 ms |
0 KB |
- |