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 ll long long int
#define F first
#define S second
#define pb push_back
const ll N = 300 + 10;
const ll LOG = 50;
const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 10;
int n, q, len, a[N], Q[N];
vector <int> all[N][N];
int main() {
cin >> n >> len;
if (n <= 300){
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n - len + 1; i++){
for (int j = 1; j <= n - len + 1; j++){
if (i == j) continue;
int dif = 0;
for (int k = 0; k < len; k++){
dif += (a[i + k] != a[j + k]);
}
for (int k = dif; k <= len; k++) all[i][k].pb(j);
}
}
for (int i = 1; i <= n - len + 1; i++){
for (int j = 0; j <= len; j++){
sort(all[i][j].begin(), all[i][j].end());
all[i][j].resize(unique(all[i][j].begin(), all[i][j].end()) - all[i][j].begin());
}
}
cin >> q;
for (int i = 0; i < q; i++){
cin >> Q[i];
}
for (int i = 0; i < q; i++){
for (int j = 1; j <= n - len + 1; j ++){
cout << all[j][Q[i]].size() << ' ';
}
cout << '\n';
}
}
else 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... |