#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,l,q,o,a[10001],c[10001],x,ans;
map<ll,ll>mp;
vector<vector<ll> >v;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin>>n>>l;
if(n>2000)
{
c[0]=1;
for(ll i=1; i<=n; i++)
c[i]=(1LL*c[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*c[j-i]*a[j])%mod;
mp[x]++;
a[i]=x;
}
cin>>q;
while(q--)
{
cin>>x;
for(ll i=0; i+l-1<n; i++)
cout<<mp[a[i]]-1<<" ";
}
return 0;
}
for(ll i=0; i<n; i++)
{
cin>>a[i];
if(!mp[a[i]])
mp[a[i]]=++o;
a[i]=mp[a[i]];
}
mp.clear();
v.resize(o+1);
for(ll i=0; i<n; i++)
v[a[i]].push_back(i);
cin>>q;
while(q--)
{
cin>>x;
x=l-x;
for(ll i=0; i+l-1<n; i++)
{
ans=0;
memset(c,0,sizeof c);
for(ll j=i; j<i+l; j++)
{
for(auto k:v[a[j]])
{
if(k-j+i>=0)
c[k-j+i]++;
}
}
for(ll j=0; j+l-1<n; j++)
if(i!=j)
ans+=(c[j]>=x);
cout<<ans<<" ";
}
cout<<endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
4 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
22 ms |
364 KB |
Output is correct |
9 |
Correct |
35 ms |
372 KB |
Output is correct |
10 |
Correct |
13 ms |
332 KB |
Output is correct |
11 |
Correct |
9 ms |
332 KB |
Output is correct |
12 |
Correct |
15 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
4 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
22 ms |
364 KB |
Output is correct |
9 |
Correct |
35 ms |
372 KB |
Output is correct |
10 |
Correct |
13 ms |
332 KB |
Output is correct |
11 |
Correct |
9 ms |
332 KB |
Output is correct |
12 |
Correct |
15 ms |
364 KB |
Output is correct |
13 |
Correct |
52 ms |
392 KB |
Output is correct |
14 |
Correct |
185 ms |
524 KB |
Output is correct |
15 |
Correct |
510 ms |
508 KB |
Output is correct |
16 |
Correct |
1720 ms |
544 KB |
Output is correct |
17 |
Correct |
215 ms |
452 KB |
Output is correct |
18 |
Correct |
325 ms |
392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
3 ms |
460 KB |
Output is correct |
4 |
Correct |
12 ms |
452 KB |
Output is correct |
5 |
Correct |
109 ms |
576 KB |
Output is correct |
6 |
Correct |
32 ms |
656 KB |
Output is correct |
7 |
Correct |
110 ms |
372 KB |
Output is correct |
8 |
Correct |
92 ms |
332 KB |
Output is correct |
9 |
Correct |
16 ms |
460 KB |
Output is correct |
10 |
Correct |
13 ms |
420 KB |
Output is correct |
11 |
Correct |
12 ms |
400 KB |
Output is correct |
12 |
Correct |
65 ms |
584 KB |
Output is correct |
13 |
Correct |
106 ms |
584 KB |
Output is correct |
14 |
Correct |
108 ms |
552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
3 ms |
460 KB |
Output is correct |
4 |
Correct |
12 ms |
452 KB |
Output is correct |
5 |
Correct |
109 ms |
576 KB |
Output is correct |
6 |
Correct |
32 ms |
656 KB |
Output is correct |
7 |
Correct |
110 ms |
372 KB |
Output is correct |
8 |
Correct |
92 ms |
332 KB |
Output is correct |
9 |
Correct |
16 ms |
460 KB |
Output is correct |
10 |
Correct |
13 ms |
420 KB |
Output is correct |
11 |
Correct |
12 ms |
400 KB |
Output is correct |
12 |
Correct |
65 ms |
584 KB |
Output is correct |
13 |
Correct |
106 ms |
584 KB |
Output is correct |
14 |
Correct |
108 ms |
552 KB |
Output is correct |
15 |
Incorrect |
18 ms |
828 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
3 ms |
332 KB |
Output is correct |
3 |
Correct |
4 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
22 ms |
364 KB |
Output is correct |
9 |
Correct |
35 ms |
372 KB |
Output is correct |
10 |
Correct |
13 ms |
332 KB |
Output is correct |
11 |
Correct |
9 ms |
332 KB |
Output is correct |
12 |
Correct |
15 ms |
364 KB |
Output is correct |
13 |
Correct |
52 ms |
392 KB |
Output is correct |
14 |
Correct |
185 ms |
524 KB |
Output is correct |
15 |
Correct |
510 ms |
508 KB |
Output is correct |
16 |
Correct |
1720 ms |
544 KB |
Output is correct |
17 |
Correct |
215 ms |
452 KB |
Output is correct |
18 |
Correct |
325 ms |
392 KB |
Output is correct |
19 |
Correct |
2 ms |
332 KB |
Output is correct |
20 |
Correct |
3 ms |
332 KB |
Output is correct |
21 |
Correct |
3 ms |
460 KB |
Output is correct |
22 |
Correct |
12 ms |
452 KB |
Output is correct |
23 |
Correct |
109 ms |
576 KB |
Output is correct |
24 |
Correct |
32 ms |
656 KB |
Output is correct |
25 |
Correct |
110 ms |
372 KB |
Output is correct |
26 |
Correct |
92 ms |
332 KB |
Output is correct |
27 |
Correct |
16 ms |
460 KB |
Output is correct |
28 |
Correct |
13 ms |
420 KB |
Output is correct |
29 |
Correct |
12 ms |
400 KB |
Output is correct |
30 |
Correct |
65 ms |
584 KB |
Output is correct |
31 |
Correct |
106 ms |
584 KB |
Output is correct |
32 |
Correct |
108 ms |
552 KB |
Output is correct |
33 |
Incorrect |
18 ms |
828 KB |
Output isn't correct |
34 |
Halted |
0 ms |
0 KB |
- |