이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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[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 i=0;i<l-1;i++){
poz.clear();
for(int j=0;j<n;j++){
if(i==j) continue;
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]});
}
}
//return 0;
for(int i=l-1;i<n;i++){
poz.clear();
for(int j=0;j<n;j++){
if(i==j) continue;
if(v[i]==v[j]) poz.push_back(j);
}
while(!dous.empty() && i-l>=dous.front().first){
pod[-dous.front().first+dous.front().second]--;
dous.pop();
}
for(int j=0;j<poz.size();j++){
pod[-i+poz[j]]++;
//cout<<i+poz[i][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]);
// cout<<j-l<<" ";
}
//cout<<"\n";
}
//return 0;
/*for(int i=0;i<n-l+1;i++){
for(int j=0;j<match[i].size();j++)
cout<<match[i][j]<<" ";
cout<<"\n";
}*/
//return 0;
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";
}
}
컴파일 시 표준 에러 (stderr) 메시지
lot.cpp: In function 'int main()':
lot.cpp:19:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for(int j=0;j<poz.size();j++){
| ~^~~~~~~~~~~
lot.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for(int j=0;j<poz.size();j++){
| ~^~~~~~~~~~~
lot.cpp:63:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | 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... |