#include <bits/stdc++.h>
#define MAXN 10005
using namespace std;
int arr[MAXN];
int dp[MAXN][MAXN]={0};
int ans[MAXN];
int main ()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n,l,k,q;
cin>>n>>l;
for(int i=1;i<=n;i++)
cin>>arr[i];
if(n<=2000){
for(int i=1;i<=n-l+1;i++)
{
for(int j=i+1;j<=n-l+1;j++)
{
int x=0;
for(int p=0;p<l;p++)
if (arr[i+p]!=arr[j+p])x++;
dp[j][x]++;
dp[i][x]++;
}
}
for(int i =1; i<=n-l+1; i++)
for (int j =0; j<= l; j++)
dp[i][j+1]+= dp[i][j];
cin>>q;
while(q--)
{
cin>>k;
for(int i=1;i<=n-l+1;i++)
cout<<dp[i][k]<<' ';
cout<<endl;
}
}
else
{
cin>>q>>k;
for (int i=1;i<=n-l+1;i++)
{
for (int j =i+1;j<=n-l+1;j++)
{
int x=0;
for(int p=0;p<l;p++)
if (arr[i+p]!=arr[j+p])x++;
if(x<=k)
{
ans[i] ++;
ans[j] ++;
}
}
cout <<ans[i]<<' ';
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
640 KB |
Output is correct |
3 |
Correct |
2 ms |
768 KB |
Output is correct |
4 |
Correct |
2 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
768 KB |
Output is correct |
7 |
Correct |
3 ms |
768 KB |
Output is correct |
8 |
Correct |
5 ms |
1024 KB |
Output is correct |
9 |
Correct |
4 ms |
1024 KB |
Output is correct |
10 |
Correct |
4 ms |
1536 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
640 KB |
Output is correct |
3 |
Correct |
2 ms |
768 KB |
Output is correct |
4 |
Correct |
2 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
768 KB |
Output is correct |
7 |
Correct |
3 ms |
768 KB |
Output is correct |
8 |
Correct |
5 ms |
1024 KB |
Output is correct |
9 |
Correct |
4 ms |
1024 KB |
Output is correct |
10 |
Correct |
4 ms |
1536 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
13 |
Correct |
27 ms |
8696 KB |
Output is correct |
14 |
Correct |
323 ms |
9324 KB |
Output is correct |
15 |
Correct |
312 ms |
9300 KB |
Output is correct |
16 |
Correct |
225 ms |
9336 KB |
Output is correct |
17 |
Correct |
255 ms |
9464 KB |
Output is correct |
18 |
Correct |
262 ms |
9464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
375 ms |
668 KB |
Output is correct |
2 |
Correct |
646 ms |
620 KB |
Output is correct |
3 |
Correct |
302 ms |
504 KB |
Output is correct |
4 |
Execution timed out |
3086 ms |
704 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
375 ms |
668 KB |
Output is correct |
2 |
Correct |
646 ms |
620 KB |
Output is correct |
3 |
Correct |
302 ms |
504 KB |
Output is correct |
4 |
Execution timed out |
3086 ms |
704 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
640 KB |
Output is correct |
3 |
Correct |
2 ms |
768 KB |
Output is correct |
4 |
Correct |
2 ms |
640 KB |
Output is correct |
5 |
Correct |
2 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
768 KB |
Output is correct |
7 |
Correct |
3 ms |
768 KB |
Output is correct |
8 |
Correct |
5 ms |
1024 KB |
Output is correct |
9 |
Correct |
4 ms |
1024 KB |
Output is correct |
10 |
Correct |
4 ms |
1536 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
13 |
Correct |
27 ms |
8696 KB |
Output is correct |
14 |
Correct |
323 ms |
9324 KB |
Output is correct |
15 |
Correct |
312 ms |
9300 KB |
Output is correct |
16 |
Correct |
225 ms |
9336 KB |
Output is correct |
17 |
Correct |
255 ms |
9464 KB |
Output is correct |
18 |
Correct |
262 ms |
9464 KB |
Output is correct |
19 |
Correct |
375 ms |
668 KB |
Output is correct |
20 |
Correct |
646 ms |
620 KB |
Output is correct |
21 |
Correct |
302 ms |
504 KB |
Output is correct |
22 |
Execution timed out |
3086 ms |
704 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |