This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int n,q,a,k,l;
vector<int>v,poz[2007],match[2007];//duze jedno do usuniecia
int pod[4007];
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 j=0;j<i;j++){
if(v[i]==v[j]){
poz[i].push_back(j);
poz[j].push_back(i);
//cout<<i<<j<<" ";
}
}
}
for(int i=0;i<l-1;i++){
for(int j=0;j<poz[i].size();j++){
pod[-i+poz[i][j]]++;
//cout<<i+poz[i][j]<<" ";
dous.push({i,poz[i][j]});
}
}
for(int i=l-1;i<n-l+1;i++){
while(!dous.empty() && i-l>=dous.front().first){
pod[-dous.front().first+dous.front().second]--;
dous.pop();
}
for(int j=0;j<poz[i].size();j++){
pod[-i+poz[i][j]]++;
//cout<<i+poz[i][j]<<" ";
dous.push({i,poz[i][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-1].push_back(pod[-i+j]);
}
cout<<"\n";
}
cin>>q;
for(int i=0;i<q;i++){//bin search po sumie pref
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 (stderr)
lot.cpp: In function 'int main()':
lot.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(int j=0;j<poz[i].size();j++){
| ~^~~~~~~~~~~~~~
lot.cpp:32:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int j=0;j<poz[i].size();j++){
| ~^~~~~~~~~~~~~~
lot.cpp:52:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for(int p=0;p<match[j].size();p++){
| ~^~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |