#include <bits/stdc++.h>
using namespace std;
#define int64
#ifdef int64
#define int int64_t
#define INF (int64_t)1e18
#else
#define INF (int)(1e9)
#endif
#ifdef LOCAL
#include "debug.hpp"
#else
#define dbg(x)
#endif
#define MOD 1000000007
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, l;
cin >> n >> l;
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
vector<vector<int>> dists(n - l + 1, vector<int>(n - l + 1, 0));
for (int i = 0; i < n - l + 1; i++) {
for (int j = 0; j < n - l + 1; j++) {
for (int k = 0; k < l; k++) {
dists[i][j] += a[i + k] != a[j + k];
}
}
sort(dists[i].begin(), dists[i].end());
}
dbg(dists);
int q;
cin >> q;
for (int w = 0; w < q; w++) {
int k;
cin >> k;
for (int i = 0; i < n - l + 1; i++) {
auto it = upper_bound(dists[i].begin(), dists[i].end(), k);
cout << it - dists[i].begin() - 1 << " ";
}
cout << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
5 ms |
460 KB |
Output is correct |
9 |
Correct |
5 ms |
460 KB |
Output is correct |
10 |
Correct |
4 ms |
844 KB |
Output is correct |
11 |
Correct |
3 ms |
952 KB |
Output is correct |
12 |
Correct |
4 ms |
844 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
5 ms |
460 KB |
Output is correct |
9 |
Correct |
5 ms |
460 KB |
Output is correct |
10 |
Correct |
4 ms |
844 KB |
Output is correct |
11 |
Correct |
3 ms |
952 KB |
Output is correct |
12 |
Correct |
4 ms |
844 KB |
Output is correct |
13 |
Correct |
105 ms |
31620 KB |
Output is correct |
14 |
Correct |
1164 ms |
14328 KB |
Output is correct |
15 |
Correct |
1158 ms |
14328 KB |
Output is correct |
16 |
Correct |
737 ms |
25168 KB |
Output is correct |
17 |
Correct |
931 ms |
22212 KB |
Output is correct |
18 |
Correct |
939 ms |
22212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
35 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
35 ms |
65540 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
5 ms |
460 KB |
Output is correct |
9 |
Correct |
5 ms |
460 KB |
Output is correct |
10 |
Correct |
4 ms |
844 KB |
Output is correct |
11 |
Correct |
3 ms |
952 KB |
Output is correct |
12 |
Correct |
4 ms |
844 KB |
Output is correct |
13 |
Correct |
105 ms |
31620 KB |
Output is correct |
14 |
Correct |
1164 ms |
14328 KB |
Output is correct |
15 |
Correct |
1158 ms |
14328 KB |
Output is correct |
16 |
Correct |
737 ms |
25168 KB |
Output is correct |
17 |
Correct |
931 ms |
22212 KB |
Output is correct |
18 |
Correct |
939 ms |
22212 KB |
Output is correct |
19 |
Runtime error |
35 ms |
65540 KB |
Execution killed with signal 9 |
20 |
Halted |
0 ms |
0 KB |
- |