Submission #1104344

# Submission time Handle Problem Language Result Execution time Memory
1104344 2024-10-23T13:36:28 Z underwaterkillerwhale Lottery (CEOI18_lot) C++17
100 / 100
616 ms 6472 KB
#include <bits/stdc++.h>
#define ll long long
#define rep(i,m,n) for(int i=(m); i<=(n); i++)
#define reb(i,m,n) for(int i=(m); i>=(n); i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair
#define fs first
#define se second
#define bit(msk, i) ((msk >> i) & 1)
#define iter(id, v) for(auto id : v)
#define pb push_back
#define SZ(v) (ll)v.size()
#define ALL(v) v.begin(),v.end()

using namespace std;

mt19937_64 rd(chrono :: steady_clock :: now ().time_since_epoch().count());
ll Rand (ll l, ll r) { return uniform_int_distribution<ll> (l, r) (rd); }

const int N = 1e4 + 7;
const int Mod = 1e6 + 3;///lon
const int INF = 1e9;
const ll BASE = 137;
const int szBL = 200;

int n, L, Q;
int a[N];
short f[2][N], g[2][N], pre[N];
short Ans[107][N], qr[107];

void solution () {
    cin >> n >> L;
    rep (i, 1, n) {
        cin >> a[i];
    }
    cin >> Q;
    rep (i, 1, Q) cin >> qr[i];
    reb (i, n, 1) {
        rep (j, 1, n) {
            f[i & 1][j] = f[(i + 1) & 1][j + 1] + (a[i] != a[j]);
        }
        if (i <= n - L) {
            rep (j, 1, n) {
                g[(i + L) & 1][j] = g[(i + L + 1) & 1][j + 1] + (a[i + L] != a[j]);
            }
        }
        if (i <= n - L + 1) {
            rep (j, 0, n) pre[j] = 0;
            rep (j, 1, n - L + 1) {
                if (i == j) continue;
                int cur_Dist = f[i & 1][j] - g[(i + L) & 1][j + L];
                pre[cur_Dist]++;
            }
            rep (j, 1, n) pre[j] += pre[j - 1];
            rep (j, 1, Q) {
                Ans[j][i] = pre[qr[j]];
            }
        }
    }
    rep (i, 1, Q) {
        rep (j, 1, n - L + 1) cout << Ans[i][j] <<" ";
        cout <<"\n";
    }
}

#define file(name) freopen(name".inp","r",stdin); \
freopen(name".out","w",stdout);
main () {
//    file("c");
    ios_base :: sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int num_Test = 1;
//    cin >> num_Test;
    while (num_Test--)
        solution();
}
/*
no bug challenge +12

*/

Compilation message

lot.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 | main () {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2516 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2556 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 2 ms 2384 KB Output is correct
9 Correct 2 ms 2384 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 2 ms 2556 KB Output is correct
12 Correct 3 ms 2384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2516 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2556 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 2 ms 2384 KB Output is correct
9 Correct 2 ms 2384 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 2 ms 2556 KB Output is correct
12 Correct 3 ms 2384 KB Output is correct
13 Correct 23 ms 2384 KB Output is correct
14 Correct 19 ms 2640 KB Output is correct
15 Correct 17 ms 2632 KB Output is correct
16 Correct 23 ms 2640 KB Output is correct
17 Correct 21 ms 2640 KB Output is correct
18 Correct 21 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 507 ms 2540 KB Output is correct
2 Correct 497 ms 2384 KB Output is correct
3 Correct 529 ms 2384 KB Output is correct
4 Correct 570 ms 2612 KB Output is correct
5 Correct 255 ms 2384 KB Output is correct
6 Correct 535 ms 2632 KB Output is correct
7 Correct 275 ms 2632 KB Output is correct
8 Correct 384 ms 2632 KB Output is correct
9 Correct 554 ms 2648 KB Output is correct
10 Correct 564 ms 2624 KB Output is correct
11 Correct 30 ms 2384 KB Output is correct
12 Correct 328 ms 2640 KB Output is correct
13 Correct 310 ms 2632 KB Output is correct
14 Correct 312 ms 2616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 507 ms 2540 KB Output is correct
2 Correct 497 ms 2384 KB Output is correct
3 Correct 529 ms 2384 KB Output is correct
4 Correct 570 ms 2612 KB Output is correct
5 Correct 255 ms 2384 KB Output is correct
6 Correct 535 ms 2632 KB Output is correct
7 Correct 275 ms 2632 KB Output is correct
8 Correct 384 ms 2632 KB Output is correct
9 Correct 554 ms 2648 KB Output is correct
10 Correct 564 ms 2624 KB Output is correct
11 Correct 30 ms 2384 KB Output is correct
12 Correct 328 ms 2640 KB Output is correct
13 Correct 310 ms 2632 KB Output is correct
14 Correct 312 ms 2616 KB Output is correct
15 Correct 487 ms 2384 KB Output is correct
16 Correct 510 ms 2620 KB Output is correct
17 Correct 566 ms 2620 KB Output is correct
18 Correct 581 ms 2632 KB Output is correct
19 Correct 575 ms 2632 KB Output is correct
20 Correct 600 ms 2632 KB Output is correct
21 Correct 578 ms 2624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2516 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2556 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 2 ms 2384 KB Output is correct
9 Correct 2 ms 2384 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 2 ms 2556 KB Output is correct
12 Correct 3 ms 2384 KB Output is correct
13 Correct 23 ms 2384 KB Output is correct
14 Correct 19 ms 2640 KB Output is correct
15 Correct 17 ms 2632 KB Output is correct
16 Correct 23 ms 2640 KB Output is correct
17 Correct 21 ms 2640 KB Output is correct
18 Correct 21 ms 2640 KB Output is correct
19 Correct 507 ms 2540 KB Output is correct
20 Correct 497 ms 2384 KB Output is correct
21 Correct 529 ms 2384 KB Output is correct
22 Correct 570 ms 2612 KB Output is correct
23 Correct 255 ms 2384 KB Output is correct
24 Correct 535 ms 2632 KB Output is correct
25 Correct 275 ms 2632 KB Output is correct
26 Correct 384 ms 2632 KB Output is correct
27 Correct 554 ms 2648 KB Output is correct
28 Correct 564 ms 2624 KB Output is correct
29 Correct 30 ms 2384 KB Output is correct
30 Correct 328 ms 2640 KB Output is correct
31 Correct 310 ms 2632 KB Output is correct
32 Correct 312 ms 2616 KB Output is correct
33 Correct 487 ms 2384 KB Output is correct
34 Correct 510 ms 2620 KB Output is correct
35 Correct 566 ms 2620 KB Output is correct
36 Correct 581 ms 2632 KB Output is correct
37 Correct 575 ms 2632 KB Output is correct
38 Correct 600 ms 2632 KB Output is correct
39 Correct 578 ms 2624 KB Output is correct
40 Correct 520 ms 3416 KB Output is correct
41 Correct 107 ms 2632 KB Output is correct
42 Correct 532 ms 3380 KB Output is correct
43 Correct 575 ms 3040 KB Output is correct
44 Correct 581 ms 3208 KB Output is correct
45 Correct 592 ms 6472 KB Output is correct
46 Correct 108 ms 2868 KB Output is correct
47 Correct 616 ms 6468 KB Output is correct
48 Correct 596 ms 4740 KB Output is correct
49 Correct 600 ms 5456 KB Output is correct