# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
112423 | SuperJumbo | Lottery (CEOI18_lot) | C++14 | 2646 ms | 8440 KiB |
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 main(){
int n,l;
scanf("%d %d",&n,&l);
vector<int> a(n);
for(int i = 0;i<n;i++)scanf("%d",&a[i]);
int q;scanf("%d",&q);
vector<int> queries;
map<int,vector<int>> ans;
for(int i = 0;i<q;i++){
int x;scanf("%d",&x);
queries.push_back(x);
ans[x] = vector<int> (n-l+1,0);
}
vector<int> v(n);
vector<int> sum(n,0);
for(int i = 0;i<n;i++){
int u = i - l;
if(i>=l){
for(int j = u+1,x = 0;j<n;x++,j++)
sum[x]-=(a[u] != a[j]);
}
for(int j = i+1,x = 0;j<n;x++,j++){
sum[x]+=(a[i] != a[j]);
if(i>=l-1){
auto y = ans.lower_bound(sum[x]);
if(y == ans.end())continue;
ans[y->first][u+1]++;
ans[y->first][u+2+x]++;
}
}
}
auto x = ans.begin(),y=x;
advance(y,1);
while(y!=ans.end()){
for(int i = 0;i<n-l+1;i++)
ans[y->first][i] += ans[x->first][i];
x = y;
advance(y,1);
}
for(auto u : queries){
for(auto v:ans[u])
printf("%d ",v);
printf("\n");
}
}
Compilation message (stderr)
# | 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... |