#include<bits/stdc++.h>
using namespace std;
int n,q,a,k,l;
vector<int>v,poz,match[2007];//duze jedno do usuniecia
int pod[10007];
queue<pair<int,int>>dous;
int main(){
cin>>n>>l;
for(int i=0;i<n;i++){
cin>>a;
v.push_back(a);
}
for(int i=0;i<l-1;i++){
poz.clear();
for(int j=i+1;j<n;j++){
if(v[i]==v[j]) poz.push_back(j);
}
for(int j=0;j<poz.size();j++){
pod[-i+poz[j]]++;
// dous.push({i,poz[j]});
}
}
for(int i=l-1;i<n;i++){
if(i!=l-1){
poz.clear();
i=i-l;
for(int j=i+1;j<n;j++){
if(v[i]==v[j]) poz.push_back(j);
}
for(int j=0;j<poz.size();j++){
pod[-i+poz[j]]--;
// dous.push({i,poz[j]});
}
i=i+l;}
poz.clear();
for(int j=i+1;j<n;j++){
if(v[i]==v[j]) poz.push_back(j);
}
for(int j=0;j<poz.size();j++){
pod[-i+poz[j]]++;
// dous.push({i,poz[j]});
}
// for(int j=l-1;j<i;j++) cout<<0<<" ";
// for(int j=i;j<n;j++)
// cout<<pod[-i+j]<<" ";
for(int j=i+1;j<n;j++){
match[i-l+1].push_back(pod[-i+j]);
match[j-l+1].push_back(pod[-i+j]);
}
}
cin>>q;
for(int i=0;i<q;i++){
cin>>k;
k=l-k;
for(int j=0;j<n-l+1;j++){
int licz=0;
for(int p=0;p<match[j].size();p++){
if(match[j][p]>=k)
licz++;}
cout<<licz<<" ";
}
cout<<"\n";
}
}
Compilation message
lot.cpp: In function 'int main()':
lot.cpp:18:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
18 | for(int j=0;j<poz.size();j++){
| ~^~~~~~~~~~~
lot.cpp:30:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | for(int j=0;j<poz.size();j++){
| ~^~~~~~~~~~~
lot.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int j=0;j<poz.size();j++){
| ~^~~~~~~~~~~
lot.cpp:57:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for(int p=0;p<match[j].size();p++){
| ~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 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 |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
3 ms |
860 KB |
Output is correct |
11 |
Correct |
2 ms |
856 KB |
Output is correct |
12 |
Correct |
4 ms |
860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 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 |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
3 ms |
860 KB |
Output is correct |
11 |
Correct |
2 ms |
856 KB |
Output is correct |
12 |
Correct |
4 ms |
860 KB |
Output is correct |
13 |
Correct |
65 ms |
16672 KB |
Output is correct |
14 |
Correct |
47 ms |
11356 KB |
Output is correct |
15 |
Correct |
52 ms |
11256 KB |
Output is correct |
16 |
Correct |
62 ms |
14972 KB |
Output is correct |
17 |
Correct |
58 ms |
14088 KB |
Output is correct |
18 |
Correct |
57 ms |
13916 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
860 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
860 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 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 |
1 ms |
600 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
3 ms |
860 KB |
Output is correct |
11 |
Correct |
2 ms |
856 KB |
Output is correct |
12 |
Correct |
4 ms |
860 KB |
Output is correct |
13 |
Correct |
65 ms |
16672 KB |
Output is correct |
14 |
Correct |
47 ms |
11356 KB |
Output is correct |
15 |
Correct |
52 ms |
11256 KB |
Output is correct |
16 |
Correct |
62 ms |
14972 KB |
Output is correct |
17 |
Correct |
58 ms |
14088 KB |
Output is correct |
18 |
Correct |
57 ms |
13916 KB |
Output is correct |
19 |
Runtime error |
3 ms |
860 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |