# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
240675 | m3r8 | Lottery (CEOI18_lot) | C++14 | 485 ms | 4476 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 <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <vector>
#define N 10010
#define ii std::pair<int,int>
int dp[N][102];
int map[N];
int seq[N];
std::vector<ii> qry;
std::vector<int> qrr;
int main(void){
int n,l,q;
scanf("%d %d",&n,&l);
for(int i = 0;i<n;i++){
scanf("%d",&seq[i]);
};
scanf("%d",&q);
int v;
for(int i = 0;i<q;i++){
scanf("%d",&v);
qry.push_back({v,i});
qrr.push_back(v);
};
std::sort(qry.begin(),qry.end(),std::less<ii>());
int idx = 0;
for(int i = 0;i<=l;i++){
if(idx >= qry.size()){
map[i] = idx;
}else if(qry[idx].first >= i){
map[i] = idx;
}else{
idx++;
map[i] = idx;
};
};
for(int i = 1;i<n-l+1;i++){
int tmp = 0;
for(int j = 0;j<n-i;j++){
if(j < l){
tmp += seq[j] != seq[j+i];
if(j == l-1){
dp[0][map[tmp]]++;
dp[i][map[tmp]]++;
};
}else{
tmp -= seq[j-l] != seq[j+i-l];
tmp += seq[j] != seq[j+i];
dp[j-l+1][map[tmp]]++;
dp[j-l+i+1][map[tmp]]++;
};
};
};
for(int i = 0;i<n-l+1;i++){
for(int j = 1;j<q;j++){
dp[i][j] += dp[i][j-1];
};
};
for(int j = 0;j<qry.size();j++){
for(int i = 0;i<n-l+1;i++){
printf("%d ",dp[i][j]);
};
puts("");
};
return 0;
};
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... |