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>
#define all(s) s.begin(),s.end()
#define F first
#define S second
using namespace std;
typedef int ll;
const ll mod=1e9+7;
ll n,q,l,a[10000],x,f[10000];
map<ll,ll>mp;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>n>>l;
f[0]=1;
for(ll i=1;i<=n;i++)
f[i]=(1LL*f[i-1]*1021)%mod;
for(ll i=0;i<n;i++)
cin>>a[i];
for(ll i=0;i+l-1<n;i++)
{
x=0;
for(ll j=i;j<i+l;j++)
x=(1LL*x+1LL*f[i-j]*a[i])%mod;
mp[x]++;
a[i]=x;
}
cin>>q;
while(q--)
{
cin>>x;
for(ll i=0;i<n;i++)
cout<<mp[a[i]]<<" ";
}
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... |