#include <bits/stdc++.h>
#define maxN 10005
using namespace std;
vector <int> v;
vector <pair<int,int>> u;
int n,l,q,k[maxN][105],s[2*maxN],ans[105],x,i,j;
void update(int koji,int p){
//cout<<koji<<" "<<p<<endl;
while(p<=u.size()){
k[koji][p]++;
p+=p & (-p);
}
}
int query(int koji,int p){
int ans=0;
while(p>0){
ans+=k[koji][p];
p-=p & (-p);
}
return ans;
}
void ispisi(int x){
int i,j;
for(i=0;i<u.size();i++){
if(u[i].second==x){
for(j=0;j<n-l+1;j++) cout<<query(j,i+1)<<" ";
}
}
cout<<endl;
}
int main() {
cin>>n>>l;
for(i=0;i<n;i++){
cin>>x;
v.push_back(x);
}
cin>>q;
for(i=0;i<q;i++){
cin>>x;
u.push_back({x,i});
}
sort(u.begin(),u.end());
for(i=1;i<=n-l;i++){
for(j=i;j<n;j++){
s[j]=s[j-1];
if(v[j]==v[j-i]) s[j]++;
//cout<<j<<" "<<s[j]<<endl;
}
for(j=0;j+l+i-1<n;j++){
int tmp,p;
tmp=s[j+l+i-1]-s[j+i-1];
p=lower_bound(u.begin(),u.end(),make_pair(l-tmp,-5))-u.begin();
//cout<<j<<" "<<i<<" "<<p<<endl;
update(j,p+1);
update(j+i,p+1);
}
for(j=0;j<n;j++) s[j]=0;
}
for(i=0;i<q;i++) ispisi(i);
return 0;
}
Compilation message
lot.cpp: In function 'void update(int, int)':
lot.cpp:12:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(p<=u.size()){
~^~~~~~~~~~
lot.cpp: In function 'void ispisi(int)':
lot.cpp:29:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0;i<u.size();i++){
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
456 KB |
Output is correct |
4 |
Correct |
2 ms |
540 KB |
Output is correct |
5 |
Correct |
2 ms |
584 KB |
Output is correct |
6 |
Correct |
2 ms |
716 KB |
Output is correct |
7 |
Correct |
2 ms |
724 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
3 ms |
724 KB |
Output is correct |
10 |
Correct |
3 ms |
804 KB |
Output is correct |
11 |
Correct |
3 ms |
804 KB |
Output is correct |
12 |
Correct |
3 ms |
924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
456 KB |
Output is correct |
4 |
Correct |
2 ms |
540 KB |
Output is correct |
5 |
Correct |
2 ms |
584 KB |
Output is correct |
6 |
Correct |
2 ms |
716 KB |
Output is correct |
7 |
Correct |
2 ms |
724 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
3 ms |
724 KB |
Output is correct |
10 |
Correct |
3 ms |
804 KB |
Output is correct |
11 |
Correct |
3 ms |
804 KB |
Output is correct |
12 |
Correct |
3 ms |
924 KB |
Output is correct |
13 |
Correct |
37 ms |
1492 KB |
Output is correct |
14 |
Correct |
24 ms |
1492 KB |
Output is correct |
15 |
Correct |
16 ms |
1492 KB |
Output is correct |
16 |
Correct |
25 ms |
1564 KB |
Output is correct |
17 |
Correct |
22 ms |
1584 KB |
Output is correct |
18 |
Correct |
22 ms |
1604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
699 ms |
5104 KB |
Output is correct |
2 |
Correct |
572 ms |
5128 KB |
Output is correct |
3 |
Correct |
373 ms |
5232 KB |
Output is correct |
4 |
Correct |
342 ms |
5232 KB |
Output is correct |
5 |
Correct |
174 ms |
5232 KB |
Output is correct |
6 |
Correct |
316 ms |
5232 KB |
Output is correct |
7 |
Correct |
285 ms |
5232 KB |
Output is correct |
8 |
Correct |
510 ms |
5232 KB |
Output is correct |
9 |
Correct |
351 ms |
5424 KB |
Output is correct |
10 |
Correct |
387 ms |
5468 KB |
Output is correct |
11 |
Correct |
23 ms |
5468 KB |
Output is correct |
12 |
Correct |
221 ms |
5468 KB |
Output is correct |
13 |
Correct |
197 ms |
5468 KB |
Output is correct |
14 |
Correct |
203 ms |
5468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
699 ms |
5104 KB |
Output is correct |
2 |
Correct |
572 ms |
5128 KB |
Output is correct |
3 |
Correct |
373 ms |
5232 KB |
Output is correct |
4 |
Correct |
342 ms |
5232 KB |
Output is correct |
5 |
Correct |
174 ms |
5232 KB |
Output is correct |
6 |
Correct |
316 ms |
5232 KB |
Output is correct |
7 |
Correct |
285 ms |
5232 KB |
Output is correct |
8 |
Correct |
510 ms |
5232 KB |
Output is correct |
9 |
Correct |
351 ms |
5424 KB |
Output is correct |
10 |
Correct |
387 ms |
5468 KB |
Output is correct |
11 |
Correct |
23 ms |
5468 KB |
Output is correct |
12 |
Correct |
221 ms |
5468 KB |
Output is correct |
13 |
Correct |
197 ms |
5468 KB |
Output is correct |
14 |
Correct |
203 ms |
5468 KB |
Output is correct |
15 |
Correct |
586 ms |
5992 KB |
Output is correct |
16 |
Correct |
337 ms |
5992 KB |
Output is correct |
17 |
Correct |
372 ms |
6012 KB |
Output is correct |
18 |
Correct |
344 ms |
6012 KB |
Output is correct |
19 |
Correct |
385 ms |
6012 KB |
Output is correct |
20 |
Correct |
345 ms |
6672 KB |
Output is correct |
21 |
Correct |
373 ms |
6672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
456 KB |
Output is correct |
4 |
Correct |
2 ms |
540 KB |
Output is correct |
5 |
Correct |
2 ms |
584 KB |
Output is correct |
6 |
Correct |
2 ms |
716 KB |
Output is correct |
7 |
Correct |
2 ms |
724 KB |
Output is correct |
8 |
Correct |
3 ms |
724 KB |
Output is correct |
9 |
Correct |
3 ms |
724 KB |
Output is correct |
10 |
Correct |
3 ms |
804 KB |
Output is correct |
11 |
Correct |
3 ms |
804 KB |
Output is correct |
12 |
Correct |
3 ms |
924 KB |
Output is correct |
13 |
Correct |
37 ms |
1492 KB |
Output is correct |
14 |
Correct |
24 ms |
1492 KB |
Output is correct |
15 |
Correct |
16 ms |
1492 KB |
Output is correct |
16 |
Correct |
25 ms |
1564 KB |
Output is correct |
17 |
Correct |
22 ms |
1584 KB |
Output is correct |
18 |
Correct |
22 ms |
1604 KB |
Output is correct |
19 |
Correct |
699 ms |
5104 KB |
Output is correct |
20 |
Correct |
572 ms |
5128 KB |
Output is correct |
21 |
Correct |
373 ms |
5232 KB |
Output is correct |
22 |
Correct |
342 ms |
5232 KB |
Output is correct |
23 |
Correct |
174 ms |
5232 KB |
Output is correct |
24 |
Correct |
316 ms |
5232 KB |
Output is correct |
25 |
Correct |
285 ms |
5232 KB |
Output is correct |
26 |
Correct |
510 ms |
5232 KB |
Output is correct |
27 |
Correct |
351 ms |
5424 KB |
Output is correct |
28 |
Correct |
387 ms |
5468 KB |
Output is correct |
29 |
Correct |
23 ms |
5468 KB |
Output is correct |
30 |
Correct |
221 ms |
5468 KB |
Output is correct |
31 |
Correct |
197 ms |
5468 KB |
Output is correct |
32 |
Correct |
203 ms |
5468 KB |
Output is correct |
33 |
Correct |
586 ms |
5992 KB |
Output is correct |
34 |
Correct |
337 ms |
5992 KB |
Output is correct |
35 |
Correct |
372 ms |
6012 KB |
Output is correct |
36 |
Correct |
344 ms |
6012 KB |
Output is correct |
37 |
Correct |
385 ms |
6012 KB |
Output is correct |
38 |
Correct |
345 ms |
6672 KB |
Output is correct |
39 |
Correct |
373 ms |
6672 KB |
Output is correct |
40 |
Correct |
1940 ms |
7508 KB |
Output is correct |
41 |
Correct |
41 ms |
7508 KB |
Output is correct |
42 |
Correct |
656 ms |
7508 KB |
Output is correct |
43 |
Correct |
518 ms |
7508 KB |
Output is correct |
44 |
Correct |
524 ms |
7508 KB |
Output is correct |
45 |
Correct |
2205 ms |
10804 KB |
Output is correct |
46 |
Correct |
51 ms |
10804 KB |
Output is correct |
47 |
Correct |
1299 ms |
11056 KB |
Output is correct |
48 |
Correct |
720 ms |
11056 KB |
Output is correct |
49 |
Correct |
722 ms |
11056 KB |
Output is correct |