Submission #162136

# Submission time Handle Problem Language Result Execution time Memory
162136 2019-11-06T16:09:38 Z Akashi Lottery (CEOI18_lot) C++14
0 / 100
758 ms 4528 KB
///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;
    }

    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

lot.cpp: In function 'int main()':
lot.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &l);
     ~~~~~^~~~~~~~~~~~~~~~
lot.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
lot.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &t);
     ~~~~~^~~~~~~~~~
lot.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &q[i].x);
         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 758 ms 4528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 758 ms 4528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -