이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e4 + 5;
vector<int> ans[N];
void solve() {
int n, k;
cin >> n >> k;
int a[n];
for(int i = 0; i < n; ++i)
cin >> a[i];
for(int i = 0; i <= n - k; ++i) {
for (int j = i + 1; j <= n - k; ++j) {
if (i == j)
continue;
int diff = 0;
for (int e = 0; e < k; ++e)
if (a[i + e] != a[j + e])
++diff;
ans[i].push_back(diff);
ans[j].push_back(diff);
}
sort(ans[i].begin(), ans[i].end());
}
cout << "\n";
int q;
cin >> q;
while(q--){
int dis;
cin >> dis;
for(int i = 0; i <= n - k; ++i){
int low = 0, high = ans[i].size() - 1, ok = -1;
while(low <= high){
int mid = (low + high) / 2;
if(ans[i][mid] <= dis){
ok = mid;
low = mid + 1;
}
else
high = mid - 1;
}
if(ok == -1) cout << "0 ";
else cout << ok + 1 << " ";
}
cout << "\n";
}
}
int main() {
fast;
int t = 1;
// cin >> t;
while(t--)
solve();
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... |