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;
const int N=1e4+10, Q=110;
int n, l, q, a[N];
int cnt[N][Q];
int qq[Q];
int mp[N];
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> l;
for (int i=1; i<=n; ++i) cin >> a[i];
cin >> q;
vector<int> vals{-1};
for (int i=1; i<=q; ++i) cin >> qq[i], vals.push_back(qq[i]);
sort(vals.begin(), vals.end());
for (int i=0, j=1; i<=n; ++i){
while (j<=q && i>vals[j]) ++j;
mp[i]=j;
}
for (int d=1; d<=n; ++d){
int cur=0;
for (int l1=1, r1=l, l2=l1+d, r2=r1+d; r2<=n; ++l1, ++r1, ++l2, ++r2){
if (l1==1){
for (int j=1; j<=l; ++j) cur+=a[l1+j-1]!=a[l2+j-1];
}else{
cur-=a[l1-1]!=a[l2-1];
cur+=a[r1]!=a[r2];
}
if (mp[cur]!=q+1) ++cnt[l1][mp[cur]], ++cnt[l2][mp[cur]];
}
}
for (int i=1; i<=n; ++i){
partial_sum(cnt[i], cnt[i]+q+1, cnt[i]);
}
for (int i=1; i<=q; ++i){
for (int j=1; j+l-1<=n; ++j) cout << cnt[j][mp[qq[i]]] << " \n"[j+l-1==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... |