This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |