Submission #134119

# Submission time Handle Problem Language Result Execution time Memory
134119 2019-07-22T06:00:43 Z SamAnd Lottery (CEOI18_lot) C++17
100 / 100
1973 ms 12448 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 10004, Q = 102;
struct ban
{
    int i;
    int d;
};
bool operator<(const ban& a, const ban& b)
{
    return a.d < b.d;
}

int n, m;
int a[N];
int q;
ban b[N];

int t[N];

int p[N];
int np[N];

int u[Q][N];
int ans[Q][N];
int hh[Q];
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    scanf("%d", &q);
    for (int i = 1; i <= q; ++i)
    {
        b[i].i = i;
        scanf("%d", &b[i].d);
    }
    sort(b + 1, b + q + 1);
    for (int d = 0; d <= m; ++d)
    {
        int l = 1, r = q;
        while ((r - l) > 4)
        {
            int m = (l + r) / 2;
            if (b[m].d >= d)
                r = m;
            else
                l = m;
        }
        bool z = false;
        for (int m = l; m <= r; ++m)
        {
            if (b[m].d >= d)
            {
                t[d] = m;
                z = true;
                break;
            }
        }
        if (!z)
            t[d] = q + 1;
    }
    for (int i = 1; i <= n; ++i)
    {
        memset(np, 0, sizeof np);
        for (int j = 1; j <= n; ++j)
        {
            np[j] = p[j - 1];
            if (a[i] != a[j])
                ++np[j];
            if (i - m >= 1 && j - m >= 1)
            {
                if (a[i - m] != a[j - m])
                    --np[j];
            }
        }
        memcpy(p, np, sizeof np);
        for (int j = m; j <= n; ++j)
        {
            if (i == j)
                continue;
            u[t[p[j]]][i]++;
            /*for (int k = 1; k <= q; ++k)
            {
                if (p[j] <= b[k].d)
                    ans[b[k].i][i]++;
            }*/
        }
    }
    for (int j = m; j <= n; ++j)
    {
        for (int i = 1; i <= q; ++i)
            ans[i][j] = ans[i - 1][j] + u[i][j];
    }
    for (int i = 1; i <= q; ++i)
        hh[b[i].i] = i;
    for (int i = 1; i <= q; ++i)
    {
        for (int j = m; j <= n; ++j)
            printf("%d ", ans[hh[i]][j]);
        printf("\n");
    }
    return 0;
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~
lot.cpp:31:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
lot.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &q);
     ~~~~~^~~~~~~~~~
lot.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &b[i].d);
         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 4 ms 632 KB Output is correct
9 Correct 4 ms 632 KB Output is correct
10 Correct 5 ms 632 KB Output is correct
11 Correct 5 ms 632 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 4 ms 632 KB Output is correct
9 Correct 4 ms 632 KB Output is correct
10 Correct 5 ms 632 KB Output is correct
11 Correct 5 ms 632 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 56 ms 516 KB Output is correct
14 Correct 38 ms 732 KB Output is correct
15 Correct 41 ms 672 KB Output is correct
16 Correct 47 ms 988 KB Output is correct
17 Correct 44 ms 1016 KB Output is correct
18 Correct 44 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1844 ms 672 KB Output is correct
2 Correct 1875 ms 712 KB Output is correct
3 Correct 1165 ms 608 KB Output is correct
4 Correct 941 ms 1020 KB Output is correct
5 Correct 529 ms 760 KB Output is correct
6 Correct 892 ms 788 KB Output is correct
7 Correct 519 ms 756 KB Output is correct
8 Correct 657 ms 764 KB Output is correct
9 Correct 930 ms 760 KB Output is correct
10 Correct 943 ms 804 KB Output is correct
11 Correct 72 ms 632 KB Output is correct
12 Correct 616 ms 632 KB Output is correct
13 Correct 618 ms 632 KB Output is correct
14 Correct 626 ms 772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1844 ms 672 KB Output is correct
2 Correct 1875 ms 712 KB Output is correct
3 Correct 1165 ms 608 KB Output is correct
4 Correct 941 ms 1020 KB Output is correct
5 Correct 529 ms 760 KB Output is correct
6 Correct 892 ms 788 KB Output is correct
7 Correct 519 ms 756 KB Output is correct
8 Correct 657 ms 764 KB Output is correct
9 Correct 930 ms 760 KB Output is correct
10 Correct 943 ms 804 KB Output is correct
11 Correct 72 ms 632 KB Output is correct
12 Correct 616 ms 632 KB Output is correct
13 Correct 618 ms 632 KB Output is correct
14 Correct 626 ms 772 KB Output is correct
15 Correct 1148 ms 892 KB Output is correct
16 Correct 889 ms 892 KB Output is correct
17 Correct 968 ms 888 KB Output is correct
18 Correct 936 ms 808 KB Output is correct
19 Correct 959 ms 888 KB Output is correct
20 Correct 941 ms 768 KB Output is correct
21 Correct 1008 ms 892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 3 ms 632 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 4 ms 632 KB Output is correct
9 Correct 4 ms 632 KB Output is correct
10 Correct 5 ms 632 KB Output is correct
11 Correct 5 ms 632 KB Output is correct
12 Correct 5 ms 632 KB Output is correct
13 Correct 56 ms 516 KB Output is correct
14 Correct 38 ms 732 KB Output is correct
15 Correct 41 ms 672 KB Output is correct
16 Correct 47 ms 988 KB Output is correct
17 Correct 44 ms 1016 KB Output is correct
18 Correct 44 ms 888 KB Output is correct
19 Correct 1844 ms 672 KB Output is correct
20 Correct 1875 ms 712 KB Output is correct
21 Correct 1165 ms 608 KB Output is correct
22 Correct 941 ms 1020 KB Output is correct
23 Correct 529 ms 760 KB Output is correct
24 Correct 892 ms 788 KB Output is correct
25 Correct 519 ms 756 KB Output is correct
26 Correct 657 ms 764 KB Output is correct
27 Correct 930 ms 760 KB Output is correct
28 Correct 943 ms 804 KB Output is correct
29 Correct 72 ms 632 KB Output is correct
30 Correct 616 ms 632 KB Output is correct
31 Correct 618 ms 632 KB Output is correct
32 Correct 626 ms 772 KB Output is correct
33 Correct 1148 ms 892 KB Output is correct
34 Correct 889 ms 892 KB Output is correct
35 Correct 968 ms 888 KB Output is correct
36 Correct 936 ms 808 KB Output is correct
37 Correct 959 ms 888 KB Output is correct
38 Correct 941 ms 768 KB Output is correct
39 Correct 1008 ms 892 KB Output is correct
40 Correct 1888 ms 2800 KB Output is correct
41 Correct 360 ms 1000 KB Output is correct
42 Correct 982 ms 3028 KB Output is correct
43 Correct 931 ms 2712 KB Output is correct
44 Correct 934 ms 2304 KB Output is correct
45 Correct 1973 ms 10344 KB Output is correct
46 Correct 363 ms 2172 KB Output is correct
47 Correct 1041 ms 12448 KB Output is correct
48 Correct 1002 ms 10160 KB Output is correct
49 Correct 1002 ms 8228 KB Output is correct