#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;
const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 10010, LOG=20;
int n, m, k, u, v, x, y, t, a, b;
int A[MAXN];
int K[MAXN];
int tof[MAXN];
int ans[105][MAXN];
int query[MAXN];
vector<int> Q;
void add(int i, int j, int x){
//cerr<<i<<' '<<j<<" "<<x<<endl;
int ind=tof[x];
ans[ind][i]++;
ans[ind][j]++;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
cin>>n>>k;
for (int i=1; i<=n; i++) cin>>A[i];
cin>>m;
for (int i=1; i<=m; i++) cin>>query[i], Q.pb(query[i]);
//Q.pb(k+1);
sort(all(Q));
Q.resize(unique(all(Q))-Q.begin());
//debugv(Q)
for (int i=0; i<=n; i++) tof[i]=lower_bound(all(Q), i)-Q.begin();
for (int i=k+1; i<=n; i++){
int val=0;
for (int j=0; j<k; j++) val+=(A[i-j]!=A[k-j]);
add(k, i, val);
for (int j=1; i+j<=n; j++){
val+=(A[j+k]!=A[i+j])-(A[j]!=A[i+j-k]);
add(j+k, i+j, val);
}
}
for (int i=1; i<=n; i++) for (int j=1; j<105; j++) ans[j][i]+=ans[j-1][i];
for (int id=1; id<=m; id++){
for (int i=k; i<=n; i++) cout<<ans[tof[query[id]]][i]<<" \n"[i==n];
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
760 KB |
Output is correct |
2 |
Correct |
2 ms |
760 KB |
Output is correct |
3 |
Correct |
2 ms |
888 KB |
Output is correct |
4 |
Correct |
3 ms |
888 KB |
Output is correct |
5 |
Correct |
2 ms |
888 KB |
Output is correct |
6 |
Correct |
2 ms |
888 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
888 KB |
Output is correct |
9 |
Correct |
3 ms |
888 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
3 ms |
888 KB |
Output is correct |
12 |
Correct |
3 ms |
888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
760 KB |
Output is correct |
2 |
Correct |
2 ms |
760 KB |
Output is correct |
3 |
Correct |
2 ms |
888 KB |
Output is correct |
4 |
Correct |
3 ms |
888 KB |
Output is correct |
5 |
Correct |
2 ms |
888 KB |
Output is correct |
6 |
Correct |
2 ms |
888 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
888 KB |
Output is correct |
9 |
Correct |
3 ms |
888 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
3 ms |
888 KB |
Output is correct |
12 |
Correct |
3 ms |
888 KB |
Output is correct |
13 |
Correct |
24 ms |
1656 KB |
Output is correct |
14 |
Correct |
15 ms |
1656 KB |
Output is correct |
15 |
Correct |
14 ms |
1656 KB |
Output is correct |
16 |
Correct |
23 ms |
1684 KB |
Output is correct |
17 |
Correct |
20 ms |
1784 KB |
Output is correct |
18 |
Correct |
21 ms |
1676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
510 ms |
4668 KB |
Output is correct |
2 |
Correct |
516 ms |
4572 KB |
Output is correct |
3 |
Correct |
514 ms |
4600 KB |
Output is correct |
4 |
Correct |
493 ms |
4624 KB |
Output is correct |
5 |
Correct |
150 ms |
4600 KB |
Output is correct |
6 |
Correct |
446 ms |
4600 KB |
Output is correct |
7 |
Correct |
150 ms |
4600 KB |
Output is correct |
8 |
Correct |
270 ms |
4728 KB |
Output is correct |
9 |
Correct |
480 ms |
4728 KB |
Output is correct |
10 |
Correct |
491 ms |
4728 KB |
Output is correct |
11 |
Correct |
25 ms |
2040 KB |
Output is correct |
12 |
Correct |
260 ms |
4544 KB |
Output is correct |
13 |
Correct |
199 ms |
4600 KB |
Output is correct |
14 |
Correct |
199 ms |
4728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
510 ms |
4668 KB |
Output is correct |
2 |
Correct |
516 ms |
4572 KB |
Output is correct |
3 |
Correct |
514 ms |
4600 KB |
Output is correct |
4 |
Correct |
493 ms |
4624 KB |
Output is correct |
5 |
Correct |
150 ms |
4600 KB |
Output is correct |
6 |
Correct |
446 ms |
4600 KB |
Output is correct |
7 |
Correct |
150 ms |
4600 KB |
Output is correct |
8 |
Correct |
270 ms |
4728 KB |
Output is correct |
9 |
Correct |
480 ms |
4728 KB |
Output is correct |
10 |
Correct |
491 ms |
4728 KB |
Output is correct |
11 |
Correct |
25 ms |
2040 KB |
Output is correct |
12 |
Correct |
260 ms |
4544 KB |
Output is correct |
13 |
Correct |
199 ms |
4600 KB |
Output is correct |
14 |
Correct |
199 ms |
4728 KB |
Output is correct |
15 |
Correct |
483 ms |
4572 KB |
Output is correct |
16 |
Correct |
420 ms |
4728 KB |
Output is correct |
17 |
Correct |
508 ms |
4728 KB |
Output is correct |
18 |
Correct |
499 ms |
4728 KB |
Output is correct |
19 |
Correct |
499 ms |
4648 KB |
Output is correct |
20 |
Correct |
503 ms |
4728 KB |
Output is correct |
21 |
Correct |
500 ms |
4728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
760 KB |
Output is correct |
2 |
Correct |
2 ms |
760 KB |
Output is correct |
3 |
Correct |
2 ms |
888 KB |
Output is correct |
4 |
Correct |
3 ms |
888 KB |
Output is correct |
5 |
Correct |
2 ms |
888 KB |
Output is correct |
6 |
Correct |
2 ms |
888 KB |
Output is correct |
7 |
Correct |
2 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
888 KB |
Output is correct |
9 |
Correct |
3 ms |
888 KB |
Output is correct |
10 |
Correct |
3 ms |
888 KB |
Output is correct |
11 |
Correct |
3 ms |
888 KB |
Output is correct |
12 |
Correct |
3 ms |
888 KB |
Output is correct |
13 |
Correct |
24 ms |
1656 KB |
Output is correct |
14 |
Correct |
15 ms |
1656 KB |
Output is correct |
15 |
Correct |
14 ms |
1656 KB |
Output is correct |
16 |
Correct |
23 ms |
1684 KB |
Output is correct |
17 |
Correct |
20 ms |
1784 KB |
Output is correct |
18 |
Correct |
21 ms |
1676 KB |
Output is correct |
19 |
Correct |
510 ms |
4668 KB |
Output is correct |
20 |
Correct |
516 ms |
4572 KB |
Output is correct |
21 |
Correct |
514 ms |
4600 KB |
Output is correct |
22 |
Correct |
493 ms |
4624 KB |
Output is correct |
23 |
Correct |
150 ms |
4600 KB |
Output is correct |
24 |
Correct |
446 ms |
4600 KB |
Output is correct |
25 |
Correct |
150 ms |
4600 KB |
Output is correct |
26 |
Correct |
270 ms |
4728 KB |
Output is correct |
27 |
Correct |
480 ms |
4728 KB |
Output is correct |
28 |
Correct |
491 ms |
4728 KB |
Output is correct |
29 |
Correct |
25 ms |
2040 KB |
Output is correct |
30 |
Correct |
260 ms |
4544 KB |
Output is correct |
31 |
Correct |
199 ms |
4600 KB |
Output is correct |
32 |
Correct |
199 ms |
4728 KB |
Output is correct |
33 |
Correct |
483 ms |
4572 KB |
Output is correct |
34 |
Correct |
420 ms |
4728 KB |
Output is correct |
35 |
Correct |
508 ms |
4728 KB |
Output is correct |
36 |
Correct |
499 ms |
4728 KB |
Output is correct |
37 |
Correct |
499 ms |
4648 KB |
Output is correct |
38 |
Correct |
503 ms |
4728 KB |
Output is correct |
39 |
Correct |
500 ms |
4728 KB |
Output is correct |
40 |
Correct |
516 ms |
5320 KB |
Output is correct |
41 |
Correct |
21 ms |
4728 KB |
Output is correct |
42 |
Correct |
514 ms |
5328 KB |
Output is correct |
43 |
Correct |
485 ms |
5240 KB |
Output is correct |
44 |
Correct |
484 ms |
5148 KB |
Output is correct |
45 |
Correct |
585 ms |
8568 KB |
Output is correct |
46 |
Correct |
27 ms |
4984 KB |
Output is correct |
47 |
Correct |
579 ms |
8568 KB |
Output is correct |
48 |
Correct |
543 ms |
6904 KB |
Output is correct |
49 |
Correct |
539 ms |
7420 KB |
Output is correct |