#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
ll power(ll x, ll y) {
ll res = 1;
while(y != 0) {
if(y%2) {
res = (res*x)%MOD;
}
x = (x*x)%MOD;
y/=2;
}
return res;
}
void solve() {
int n, l; cin >> n >> l;
int a[n+1];
for(int i=0;i<n;i++) {
cin >> a[i];
}
int dp[n-l+1][l+1];
for(int i=0;i<n-l+1;i++) {
for(int j=0;j<=l;j++) {
dp[i][j] = 0;
}
}
for(int i=0;i<n-l+1;i++) {
for(int j=0;j<n-l+1;j++) {
int m = 0;
if(i!=j) {
for(int k = 0;k<l;k++) {
m += (a[i+k] == a[j+k]);
}
dp[i][m]++;
}
}
}
int q; cin >> q;
for(int c=0;c<q;c++) {
int k; cin >> k;
for(int i=0;i<n-l+1;i++) {
int ans = 0;
for(int j = l-k;j<=l;j++) {
ans += dp[i][j];
}
cout << ans << " ";
}
cout << endl;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
// int t; cin >> t;
// while(t--)
solve();
char dksfjn;
cin >> dksfjn;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
3 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
3 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
13 ms |
348 KB |
Output is correct |
14 |
Correct |
798 ms |
3940 KB |
Output is correct |
15 |
Correct |
815 ms |
3956 KB |
Output is correct |
16 |
Correct |
498 ms |
2004 KB |
Output is correct |
17 |
Correct |
640 ms |
2648 KB |
Output is correct |
18 |
Correct |
638 ms |
2652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
242 ms |
604 KB |
Output is correct |
2 |
Correct |
441 ms |
760 KB |
Output is correct |
3 |
Correct |
247 ms |
852 KB |
Output is correct |
4 |
Execution timed out |
3072 ms |
8284 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
242 ms |
604 KB |
Output is correct |
2 |
Correct |
441 ms |
760 KB |
Output is correct |
3 |
Correct |
247 ms |
852 KB |
Output is correct |
4 |
Execution timed out |
3072 ms |
8284 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
3 ms |
348 KB |
Output is correct |
9 |
Correct |
4 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
3 ms |
344 KB |
Output is correct |
13 |
Correct |
13 ms |
348 KB |
Output is correct |
14 |
Correct |
798 ms |
3940 KB |
Output is correct |
15 |
Correct |
815 ms |
3956 KB |
Output is correct |
16 |
Correct |
498 ms |
2004 KB |
Output is correct |
17 |
Correct |
640 ms |
2648 KB |
Output is correct |
18 |
Correct |
638 ms |
2652 KB |
Output is correct |
19 |
Correct |
242 ms |
604 KB |
Output is correct |
20 |
Correct |
441 ms |
760 KB |
Output is correct |
21 |
Correct |
247 ms |
852 KB |
Output is correct |
22 |
Execution timed out |
3072 ms |
8284 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |