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
const int mxn=1e4+5,M=1e9+7;
ll ans[mxn],n,q,a[mxn],l,base=727;
map<int,int>mp;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>l;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<=n-l+1;i++){
ll hs=0;
for(int j=i;j<i+l;j++){
hs=((hs*base)%M+a[j])%M;
}
ans[i]=hs;
mp[hs]++;
}
cin>>q;
for(int i=1;i<=q;i++){
int x;
cin>>x;
for(int j=1;j<=n-l+1;j++){
cout<<mp[ans[j]]-1<<" ";
}
cout<<'\n';
}
}
# | 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... |