# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
162137 | Akashi | Lottery (CEOI18_lot) | C++14 | 806 ms | 4512 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.
///better top wins
#include <bits/stdc++.h>
using namespace std;
struct query{
int x, p;
bool operator < (const query &aux)const{
if(x != aux.x) return x < aux.x;
return p < aux.p;
}
};
query q[105];
int n, l, t;
int a[10005], f[10005];
int dp[10005][105];
void add(int p, int x){
int st = 1, dr = t;
while(st <= dr){
int mij = (st + dr) / 2;
if(q[mij].x < x) st = mij + 1;
else dr = mij - 1;
}
if(q[st].x == x) ++dr;
dp[p][dr] += 1;
}
int main()
{
// freopen("1.in", "r", stdin);
scanf("%d%d", &n, &l);
for(int i = 1; i <= n ; ++i)
scanf("%d", &a[i]);
scanf("%d", &t);
for(int i = 1; i <= t ; ++i){
scanf("%d", &q[i].x);
q[i].p = i;
}
sort(q + 1, q + t + 1);
for(int start = 2; start <= n - l + 1 ; ++start){
int i = 1, j = start, dif = 0;
for(int t = 1; t <= l ; ++t, ++i, ++j) if(a[i] != a[j]) ++dif;
add(1, dif);
add(start, dif);
while(j <= n){
if(a[i - l] != a[j - l]) --dif;
if(a[i] != a[j]) ++dif;
add(i - l + 1, dif);
add(j - l + 1, dif);
++i; ++j;
}
}
for(int i = 1; i <= t ; ++i) f[q[i].p] = i;
for(int i = 1; i <= n - l + 1 ; ++i){
for(int j = 1; j <= t ; ++j)
dp[i][j] += dp[i][j - 1];
}
for(int i = 1; i <= t ; ++i){
for(int j = 1; j <= n - l + 1 ; ++j)
printf("%d ", dp[j][f[i]]);
printf("\n");
}
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... |