답안 #1030586

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1030586 2024-07-22T07:09:43 Z vjudge1 Lottery (CEOI18_lot) C++14
100 / 100
161 ms 8352 KB
#include<bits/stdc++.h>


using namespace std;

const int MAXN = 1e4 + 5;

int n, l, q, a[MAXN];

int mq[MAXN], nxt[MAXN] , ans[105][MAXN];

bool idx[MAXN];

vector<int> con;


void solve()
{
    cin >> n >> l;

    for(int i = 1; i <= n; i++) cin >> a[i];

    cin >> q;

    for(int i = 1; i <= q; i++)
    {
        cin >> mq[i];
        idx[mq[i]] = 1;

        con.push_back(mq[i]);
    }

    sort(con.begin(),con.end());
    con.erase(unique(con.begin(),con.end()),con.end());

    int k = con.size() + 1;

    for(int i = n; i >= 0; i--)
    {
        if(idx[i])k--;
        nxt[i] = k;
    }


    vector<int> f(n + 5,0);
    
    for(int len = 1; len <= n; len++)
    {
        for(int i = 1; i <= n; i++)
        {
            f[i] = 0;
        }
        for(int i = 1; i + len <= n; i++)
        {
            f[i] = f[i - 1] + (a[i] != a[i + len]);
        }
        for(int i = 1; i + l - 1 <= n; i++)
        {
            if(i + len + l - 1 > n)break;
            int cost = nxt[f[i + l - 1] - f[i - 1]];
            ans[cost][i]++;
            ans[cost][i + len]++;
        }
    }

    for(int i = 1; i <= con.size(); i++)
    {
        for(int j = 1; j <= n; j++)
        {
            ans[i][j] += ans[i - 1][j];
        }
    }
    
    // truy van 

    for(int i = 1; i <= q; i++)
    {
        int x = lower_bound(con.begin(),con.end(),mq[i]) - con.begin() + 1;
        for(int j = 1; j <= n - l + 1; j++)
        {
            cout << ans[x][j] << " \n"[j == n - l + 1];
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

Compilation message

lot.cpp: In function 'void solve()':
lot.cpp:66:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |     for(int i = 1; i <= con.size(); i++)
      |                    ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 6 ms 2396 KB Output is correct
14 Correct 5 ms 2524 KB Output is correct
15 Correct 4 ms 2576 KB Output is correct
16 Correct 7 ms 2604 KB Output is correct
17 Correct 6 ms 2652 KB Output is correct
18 Correct 6 ms 2576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 124 ms 604 KB Output is correct
2 Correct 120 ms 672 KB Output is correct
3 Correct 118 ms 684 KB Output is correct
4 Correct 126 ms 744 KB Output is correct
5 Correct 59 ms 696 KB Output is correct
6 Correct 108 ms 736 KB Output is correct
7 Correct 59 ms 604 KB Output is correct
8 Correct 87 ms 600 KB Output is correct
9 Correct 123 ms 740 KB Output is correct
10 Correct 121 ms 740 KB Output is correct
11 Correct 7 ms 344 KB Output is correct
12 Correct 70 ms 704 KB Output is correct
13 Correct 68 ms 604 KB Output is correct
14 Correct 67 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 124 ms 604 KB Output is correct
2 Correct 120 ms 672 KB Output is correct
3 Correct 118 ms 684 KB Output is correct
4 Correct 126 ms 744 KB Output is correct
5 Correct 59 ms 696 KB Output is correct
6 Correct 108 ms 736 KB Output is correct
7 Correct 59 ms 604 KB Output is correct
8 Correct 87 ms 600 KB Output is correct
9 Correct 123 ms 740 KB Output is correct
10 Correct 121 ms 740 KB Output is correct
11 Correct 7 ms 344 KB Output is correct
12 Correct 70 ms 704 KB Output is correct
13 Correct 68 ms 604 KB Output is correct
14 Correct 67 ms 716 KB Output is correct
15 Correct 113 ms 672 KB Output is correct
16 Correct 104 ms 752 KB Output is correct
17 Correct 109 ms 604 KB Output is correct
18 Correct 117 ms 748 KB Output is correct
19 Correct 118 ms 764 KB Output is correct
20 Correct 116 ms 764 KB Output is correct
21 Correct 119 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 6 ms 2396 KB Output is correct
14 Correct 5 ms 2524 KB Output is correct
15 Correct 4 ms 2576 KB Output is correct
16 Correct 7 ms 2604 KB Output is correct
17 Correct 6 ms 2652 KB Output is correct
18 Correct 6 ms 2576 KB Output is correct
19 Correct 124 ms 604 KB Output is correct
20 Correct 120 ms 672 KB Output is correct
21 Correct 118 ms 684 KB Output is correct
22 Correct 126 ms 744 KB Output is correct
23 Correct 59 ms 696 KB Output is correct
24 Correct 108 ms 736 KB Output is correct
25 Correct 59 ms 604 KB Output is correct
26 Correct 87 ms 600 KB Output is correct
27 Correct 123 ms 740 KB Output is correct
28 Correct 121 ms 740 KB Output is correct
29 Correct 7 ms 344 KB Output is correct
30 Correct 70 ms 704 KB Output is correct
31 Correct 68 ms 604 KB Output is correct
32 Correct 67 ms 716 KB Output is correct
33 Correct 113 ms 672 KB Output is correct
34 Correct 104 ms 752 KB Output is correct
35 Correct 109 ms 604 KB Output is correct
36 Correct 117 ms 748 KB Output is correct
37 Correct 118 ms 764 KB Output is correct
38 Correct 116 ms 764 KB Output is correct
39 Correct 119 ms 760 KB Output is correct
40 Correct 118 ms 3404 KB Output is correct
41 Correct 40 ms 2900 KB Output is correct
42 Correct 128 ms 3412 KB Output is correct
43 Correct 110 ms 3112 KB Output is correct
44 Correct 104 ms 3156 KB Output is correct
45 Correct 161 ms 8280 KB Output is correct
46 Correct 40 ms 4692 KB Output is correct
47 Correct 144 ms 8352 KB Output is correct
48 Correct 138 ms 6228 KB Output is correct
49 Correct 133 ms 6912 KB Output is correct