#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
const int N=1e4+1;
int a[N],l,n;
bool posa=0;
map<int,int> ans[N];
vector<vector<int>> hp;
void level_up()
{
if(posa)
return;
for(int i=0;i<(n-l+1);i++)
{
for(int j=i+1;j<(n-l+1);j++)
{
int c=0;
for(int dl=0;dl<l;dl++)
{
c+=(hp[i][dl]!=hp[j][dl]);
}
ans[i][c]++;
ans[j][c]++;
}
}
posa=1;
}
int main()
{
cin>>n>>l;
for(int i=0;i<n;i++)
cin>>a[i];
int q;
cin>>q;
if(q==1)
{
int k;
cin>>k;
if(k==0)
{
// using Trie;
map<vector<int>,int> cnt;
for(int i=0;(i+l-1)<n;i++)
{
vector<int> ap;
for(int j=0;j<l;j++)
ap.push_back(a[i+j]);
cnt[ap]++;
}
for(int i=0;(i+l-1)<n;i++)
{
vector<int> ap;
for(int j=0;j<l;j++)
ap.push_back(a[i+j]);
cout<<cnt[ap]<<' ';
}
cout<<'\n';
}
else
{
for(int i=0;(i+l-1)<n;i++)
{
vector<int> ap;
for(int j=0;j<l;j++)
ap.push_back(a[i+j]);
hp.push_back(ap);
}
level_up();
for(int i=0;(i+l-1)<n;i++)
{
int sp=0;
for(int lp=0;lp<=k;lp++)
if(ans[i].find(lp)!=ans[i].end())
sp+=ans[i][lp];
cout<<sp<<' ';
}
cout<<'\n';
}
}
else
{
for(int i=0;(i+l-1)<n;i++)
{
vector<int> ap;
for(int j=0;j<l;j++)
ap.push_back(a[i+j]);
hp.push_back(ap);
}
level_up();
while(q--)
{
int k;
cin>>k;
for(int i=0;(i+l-1)<n;i++)
{
int sp=0;
for(int lp=0;lp<=k;lp++)
if(ans[i].find(lp)!=ans[i].end())
sp+=ans[i][lp];
cout<<sp<<' ';
}
cout<<'\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |