Submission #827625

# Submission time Handle Problem Language Result Execution time Memory
827625 2023-08-16T15:24:49 Z Ronin13 Lottery (CEOI18_lot) C++17
100 / 100
1617 ms 8292 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <bitset>
#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#define ll long long 
#define ull unsigned ll
#define f first
#define s second 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back

using namespace std;
const int nmax = 15001;

int ans[nmax];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    int l; cin >> l;
    int a[n + 1];
    int b[n + 1];
    fill(b, b + n + 1, 0);
    for(int i  = 1; i <= n; i++){
        cin >> a[i];
    }
    int q; cin >> q;
    int cnt[n + 1][q];
    vector <int> vec;
    int k[q + 1];
    for(int i = 1; i <= q; i++){
        int x; cin >> x;
        k[i] = x;
        vec.pb(x);
    }
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    for(int i = 1; i <= n; i++){
        for(int j =0; j < q; j++)
            cnt[i][j] = 0;
    }
    for(int d = 1; d <= n; d++){
        fill(b, b + n + 1, 0);
        for(int j = 1; j <= n - d; j++){
            b[j] = (a[j] != a[j + d]);
            b[j] += b[j - 1];
        }
        for(int i = 1; i <= n - l - d + 1; i++){
            int val = b[i + l - 1] - b[i - 1];
            int  x= lower_bound(vec.begin(), vec.end(), val) - vec.begin();
            if(x == vec.size()) continue;
            cnt[i][x]++;
        }
    }
    for(int d = 1; d <= n; d++){
        fill(b, b + n + 1, 0);
        for(int j = d + 1; j <= n; j++){
            b[j] = (a[j] != a[j - d]);
            b[j] += b[j - 1];
        }
        for(int i = d + 1; i <= n - l + 1; i++){
            int val = b[i + l - 1] - b[i - 1];
            int  x= lower_bound(vec.begin(), vec.end(), val) - vec.begin();
            if(x == vec.size()) continue;
            cnt[i][x]++;
        }
    }
    for(int j = 1; j < q; j++){
        for(int i = 1; i <= n; i++)
        cnt[i][j] += cnt[i][j - 1];
    }
    for(int j = 1; j <= q; j++){
        int ind = 0;
        for(int i = 0; i < vec.size(); i++)
            if(k[j] == vec[i]) ind = i;
        for(int i = 1; i <= n - l + 1; i++){
            cout << cnt[i][ind] << ' ';
        }
        cout << "\n";
    }
    return 0;
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:61:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |             if(x == vec.size()) continue;
      |                ~~^~~~~~~~~~~~~
lot.cpp:74:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |             if(x == vec.size()) continue;
      |                ~~^~~~~~~~~~~~~
lot.cpp:84:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   84 |         for(int i = 0; i < vec.size(); i++)
      |                        ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 31 ms 376 KB Output is correct
14 Correct 21 ms 508 KB Output is correct
15 Correct 19 ms 440 KB Output is correct
16 Correct 31 ms 516 KB Output is correct
17 Correct 27 ms 516 KB Output is correct
18 Correct 28 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 725 ms 440 KB Output is correct
2 Correct 560 ms 460 KB Output is correct
3 Correct 552 ms 456 KB Output is correct
4 Correct 599 ms 520 KB Output is correct
5 Correct 347 ms 516 KB Output is correct
6 Correct 512 ms 520 KB Output is correct
7 Correct 304 ms 532 KB Output is correct
8 Correct 356 ms 588 KB Output is correct
9 Correct 568 ms 528 KB Output is correct
10 Correct 537 ms 512 KB Output is correct
11 Correct 36 ms 340 KB Output is correct
12 Correct 348 ms 488 KB Output is correct
13 Correct 366 ms 464 KB Output is correct
14 Correct 359 ms 532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 725 ms 440 KB Output is correct
2 Correct 560 ms 460 KB Output is correct
3 Correct 552 ms 456 KB Output is correct
4 Correct 599 ms 520 KB Output is correct
5 Correct 347 ms 516 KB Output is correct
6 Correct 512 ms 520 KB Output is correct
7 Correct 304 ms 532 KB Output is correct
8 Correct 356 ms 588 KB Output is correct
9 Correct 568 ms 528 KB Output is correct
10 Correct 537 ms 512 KB Output is correct
11 Correct 36 ms 340 KB Output is correct
12 Correct 348 ms 488 KB Output is correct
13 Correct 366 ms 464 KB Output is correct
14 Correct 359 ms 532 KB Output is correct
15 Correct 513 ms 440 KB Output is correct
16 Correct 500 ms 520 KB Output is correct
17 Correct 559 ms 468 KB Output is correct
18 Correct 561 ms 516 KB Output is correct
19 Correct 552 ms 516 KB Output is correct
20 Correct 542 ms 648 KB Output is correct
21 Correct 562 ms 532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 31 ms 376 KB Output is correct
14 Correct 21 ms 508 KB Output is correct
15 Correct 19 ms 440 KB Output is correct
16 Correct 31 ms 516 KB Output is correct
17 Correct 27 ms 516 KB Output is correct
18 Correct 28 ms 492 KB Output is correct
19 Correct 725 ms 440 KB Output is correct
20 Correct 560 ms 460 KB Output is correct
21 Correct 552 ms 456 KB Output is correct
22 Correct 599 ms 520 KB Output is correct
23 Correct 347 ms 516 KB Output is correct
24 Correct 512 ms 520 KB Output is correct
25 Correct 304 ms 532 KB Output is correct
26 Correct 356 ms 588 KB Output is correct
27 Correct 568 ms 528 KB Output is correct
28 Correct 537 ms 512 KB Output is correct
29 Correct 36 ms 340 KB Output is correct
30 Correct 348 ms 488 KB Output is correct
31 Correct 366 ms 464 KB Output is correct
32 Correct 359 ms 532 KB Output is correct
33 Correct 513 ms 440 KB Output is correct
34 Correct 500 ms 520 KB Output is correct
35 Correct 559 ms 468 KB Output is correct
36 Correct 561 ms 516 KB Output is correct
37 Correct 552 ms 516 KB Output is correct
38 Correct 542 ms 648 KB Output is correct
39 Correct 562 ms 532 KB Output is correct
40 Correct 930 ms 1948 KB Output is correct
41 Correct 261 ms 1264 KB Output is correct
42 Correct 751 ms 1968 KB Output is correct
43 Correct 744 ms 1652 KB Output is correct
44 Correct 708 ms 1768 KB Output is correct
45 Correct 1617 ms 8156 KB Output is correct
46 Correct 270 ms 4668 KB Output is correct
47 Correct 1132 ms 8292 KB Output is correct
48 Correct 980 ms 6476 KB Output is correct
49 Correct 959 ms 7084 KB Output is correct