Submission #868131

# Submission time Handle Problem Language Result Execution time Memory
868131 2023-10-30T13:18:32 Z Cookie Lottery (CEOI18_lot) C++14
100 / 100
1012 ms 8276 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("HCN.INP");
ofstream fout("HCN.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
//using u128 = __uint128_t;
//const int x[4] = {1, -1, 0, 0};
//const int y[4] = {0, 0, 1, -1};
const ll mod = 1e9 + 9;
const int mxn = 1e5 + 5, mxq = 2e5 + 5, sq = 200, mxv = 2e6 + 5;
const ll inf = 1e17 + 5;
//const int base= (1 << 18);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, l;
int a[10005], pref[105][10005], to[10005], k[105];
int res = 0, ok = 0;
void add(int diag, int row){
    int col = diag - n + row;
    if(col >= 1 && col <= n){
        ok++;
        res += (a[row] != a[col]);
    }
}
void rem(int diag, int row){
    int col = diag - n + row;
    if(col >= 1 && col <= n){
        ok--;
        res -= (a[row] != a[col]);
    }
}
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> l;
    for(int i = 1; i <= n; i++)cin >> a[i];
    int q; cin >> q;
    vt<int>comp;
    forr(i, 0, q){
        cin >> k[i];
        comp.pb(k[i]);
    }
    sort(comp.begin(), comp.end()); comp.resize(unique(comp.begin(), comp.end()) - comp.begin());
    for(int i = 0; i <= comp[0]; i++)to[i] = 0;
    for(int i = 0; i < sz(comp) - 1; i++){
        for(int j = comp[i] + 1; j <= comp[i + 1]; j++){
            to[j] = i + 1;
        }
    }
    for(int i = comp.back() + 1; i <= l; i++){
        to[i] = sz(comp);
    }
    for(int i = 1; i <= n + n - 1; i++){
        res = ok = 0; 
        if(i == n)continue;
        for(int j = 1; j <= l; j++)add(i, j);
        if(ok == l){
            pref[to[res]][1]++;
        }
        
        for(int j = 2; j + l - 1 <= n; j++){
            rem(i, j - 1);
            add(i, j + l - 1);
            if(ok == l){
                pref[to[res]][j]++;
            }
        }
        
        
    }
    for(int i = 1; i + l - 1 <= n; i++){
        for(int j = 1; j < sz(comp); j++){
            pref[j][i] += pref[j - 1][i];
        }
    }
    for(int i = 0; i < q; i++){
        
        for(int j = 1; j + l - 1 <= n; j++){
            cout << pref[to[k[i]]][j] << " ";
        }
        cout << "\n";
    }
    return(0);
}
# Verdict Execution time Memory 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 2396 KB Output is correct
7 Correct 1 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 2 ms 2396 KB Output is correct
11 Correct 2 ms 2396 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
# Verdict Execution time Memory 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 2396 KB Output is correct
7 Correct 1 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 2 ms 2396 KB Output is correct
11 Correct 2 ms 2396 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 48 ms 2564 KB Output is correct
14 Correct 34 ms 2548 KB Output is correct
15 Correct 36 ms 2528 KB Output is correct
16 Correct 38 ms 2640 KB Output is correct
17 Correct 37 ms 2392 KB Output is correct
18 Correct 39 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 947 ms 568 KB Output is correct
2 Correct 965 ms 776 KB Output is correct
3 Correct 951 ms 600 KB Output is correct
4 Correct 958 ms 560 KB Output is correct
5 Correct 702 ms 512 KB Output is correct
6 Correct 913 ms 792 KB Output is correct
7 Correct 656 ms 600 KB Output is correct
8 Correct 762 ms 612 KB Output is correct
9 Correct 912 ms 824 KB Output is correct
10 Correct 911 ms 596 KB Output is correct
11 Correct 69 ms 348 KB Output is correct
12 Correct 661 ms 348 KB Output is correct
13 Correct 713 ms 516 KB Output is correct
14 Correct 699 ms 792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 947 ms 568 KB Output is correct
2 Correct 965 ms 776 KB Output is correct
3 Correct 951 ms 600 KB Output is correct
4 Correct 958 ms 560 KB Output is correct
5 Correct 702 ms 512 KB Output is correct
6 Correct 913 ms 792 KB Output is correct
7 Correct 656 ms 600 KB Output is correct
8 Correct 762 ms 612 KB Output is correct
9 Correct 912 ms 824 KB Output is correct
10 Correct 911 ms 596 KB Output is correct
11 Correct 69 ms 348 KB Output is correct
12 Correct 661 ms 348 KB Output is correct
13 Correct 713 ms 516 KB Output is correct
14 Correct 699 ms 792 KB Output is correct
15 Correct 923 ms 760 KB Output is correct
16 Correct 882 ms 808 KB Output is correct
17 Correct 988 ms 808 KB Output is correct
18 Correct 950 ms 524 KB Output is correct
19 Correct 926 ms 636 KB Output is correct
20 Correct 916 ms 764 KB Output is correct
21 Correct 926 ms 504 KB Output is correct
# Verdict Execution time Memory 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 2396 KB Output is correct
7 Correct 1 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 2 ms 2396 KB Output is correct
11 Correct 2 ms 2396 KB Output is correct
12 Correct 2 ms 2396 KB Output is correct
13 Correct 48 ms 2564 KB Output is correct
14 Correct 34 ms 2548 KB Output is correct
15 Correct 36 ms 2528 KB Output is correct
16 Correct 38 ms 2640 KB Output is correct
17 Correct 37 ms 2392 KB Output is correct
18 Correct 39 ms 2396 KB Output is correct
19 Correct 947 ms 568 KB Output is correct
20 Correct 965 ms 776 KB Output is correct
21 Correct 951 ms 600 KB Output is correct
22 Correct 958 ms 560 KB Output is correct
23 Correct 702 ms 512 KB Output is correct
24 Correct 913 ms 792 KB Output is correct
25 Correct 656 ms 600 KB Output is correct
26 Correct 762 ms 612 KB Output is correct
27 Correct 912 ms 824 KB Output is correct
28 Correct 911 ms 596 KB Output is correct
29 Correct 69 ms 348 KB Output is correct
30 Correct 661 ms 348 KB Output is correct
31 Correct 713 ms 516 KB Output is correct
32 Correct 699 ms 792 KB Output is correct
33 Correct 923 ms 760 KB Output is correct
34 Correct 882 ms 808 KB Output is correct
35 Correct 988 ms 808 KB Output is correct
36 Correct 950 ms 524 KB Output is correct
37 Correct 926 ms 636 KB Output is correct
38 Correct 916 ms 764 KB Output is correct
39 Correct 926 ms 504 KB Output is correct
40 Correct 1006 ms 3456 KB Output is correct
41 Correct 511 ms 2648 KB Output is correct
42 Correct 937 ms 3716 KB Output is correct
43 Correct 936 ms 3040 KB Output is correct
44 Correct 994 ms 3240 KB Output is correct
45 Correct 1012 ms 8268 KB Output is correct
46 Correct 574 ms 3440 KB Output is correct
47 Correct 987 ms 8276 KB Output is correct
48 Correct 965 ms 5988 KB Output is correct
49 Correct 1000 ms 6992 KB Output is correct