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;
int n,l,i,j,k,m,d;
int mas[100001],fix[100001],where[100001],pre[10001][102],ans[101][10001];
pair <int,int> q[101];
int main() {
cin>>n>>l;
for (i=1;i<=n;i++)
cin>>mas[i];
cin>>m;
for (i=1;i<=m;i++) {
cin>>d;
q[i]={d,i};
}
sort(q+1,q+m+1);
for (i=m;i>0;i--)
where[q[i].first]=i;
for (i=10000;i>=0;i--)
if (!where[i])
where[i]=where[i+1];
for (d=1;d<=(n-l);d++) {
for (i=1;i<=n;i++) {
fix[i]=fix[i-1];
if (mas[i]==mas[i+d])
fix[i]++;
}
for (i=1;(i+d)<=(n-l+1);i++) {
pre[i][where[l-fix[i+l-1]+fix[i-1]]]++;
pre[i+d][where[l-fix[i+l-1]+fix[i-1]]]++;
}
}
for (i=1;i<=m;i++)
for (j=1;j<=(n-l+1);j++) {
ans[q[i].second][j]=pre[j][i];
pre[j][i+1]+=pre[j][i];
}
for (i=1;i<=m;i++) {
for (j=1;j<(n-l+1);j++)
cout<<ans[i][j]<<" ";
cout<<ans[i][n-l+1]<<endl;
}
}
# | 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... |