Submission #1108414

# Submission time Handle Problem Language Result Execution time Memory
1108414 2024-11-04T04:52:51 Z koukirocks Lottery (CEOI18_lot) C++17
100 / 100
344 ms 12140 KB
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("popcnt")
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MAX=2e5+10,P=1e9+7;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;
const ldb eps=1e-6;
const ldb PI=acos(-1.0);
const int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
template<typename T>
using vvector = vector<vector<T>>;

vector<pii> qry;

int main() {
    speed;
    int n,l;
    cin>>n>>l;
    vector<int> a(n+1);
    for (int i=0;i<n;i++) {
        cin>>a[i];
    }
    int q;
    cin>>q;
    qry.resize(q);
    for (int i=0;i<q;i++) {
        cin>>qry[i].F;
        qry[i].S=i;
    }
    vvector<int> ans(q,vector<int>(n));
    sort(all(qry),[&](pii a,pii b){
        return a.F<b.F;
    });
    vector<int> ntk(l+1);
    int id=q;
    for (int i=l;i>=0;i--) {
        while (id>0 and qry[id-1].F>=i) id--;
        ntk[i]=id;
    }
    for (int g=1;g+l<=n;g++) {
        short now=0;
        for (int i=0;i<l;i++) {
            if (a[i]!=a[i+g]) now++;
        }
        for (int i=0;i+g+l<=n;i++) {
            if (ntk[now]!=q) {
                ans[ntk[now]][i]++;
                ans[ntk[now]][i+g]++;
            }
            now-=(a[i]!=a[i+g]);
            now+=(a[i+l]!=a[i+g+l]);
        }
    }
    for (int i=0;i<=n-l;i++) {
        for (int j=1;j<q;j++) ans[j][i]+=ans[j-1][i];
    }
    vvector<int> aa(q,vector<int>(n-l+1));
    for (int i=0;i<q;i++) {
        for (int j=0;j<=n-l;j++) aa[qry[i].S][j]=ans[i][j];
    }
    for (int i=0;i<q;i++) {
        for (int j=0;j<=n-l;j++) cout<<aa[i][j]<<" ";
        cout<<"\n";
    }
    return 0;
}

/*
10 10
2 34 545 56 3 3 65 2 7 6
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 560 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 560 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 12 ms 512 KB Output is correct
14 Correct 7 ms 592 KB Output is correct
15 Correct 3 ms 592 KB Output is correct
16 Correct 9 ms 848 KB Output is correct
17 Correct 5 ms 592 KB Output is correct
18 Correct 6 ms 628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 167 ms 560 KB Output is correct
2 Correct 103 ms 568 KB Output is correct
3 Correct 93 ms 564 KB Output is correct
4 Correct 90 ms 580 KB Output is correct
5 Correct 53 ms 564 KB Output is correct
6 Correct 82 ms 668 KB Output is correct
7 Correct 80 ms 676 KB Output is correct
8 Correct 153 ms 664 KB Output is correct
9 Correct 95 ms 664 KB Output is correct
10 Correct 113 ms 668 KB Output is correct
11 Correct 6 ms 336 KB Output is correct
12 Correct 50 ms 636 KB Output is correct
13 Correct 43 ms 668 KB Output is correct
14 Correct 50 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 167 ms 560 KB Output is correct
2 Correct 103 ms 568 KB Output is correct
3 Correct 93 ms 564 KB Output is correct
4 Correct 90 ms 580 KB Output is correct
5 Correct 53 ms 564 KB Output is correct
6 Correct 82 ms 668 KB Output is correct
7 Correct 80 ms 676 KB Output is correct
8 Correct 153 ms 664 KB Output is correct
9 Correct 95 ms 664 KB Output is correct
10 Correct 113 ms 668 KB Output is correct
11 Correct 6 ms 336 KB Output is correct
12 Correct 50 ms 636 KB Output is correct
13 Correct 43 ms 668 KB Output is correct
14 Correct 50 ms 844 KB Output is correct
15 Correct 181 ms 592 KB Output is correct
16 Correct 79 ms 592 KB Output is correct
17 Correct 110 ms 672 KB Output is correct
18 Correct 91 ms 592 KB Output is correct
19 Correct 93 ms 664 KB Output is correct
20 Correct 101 ms 592 KB Output is correct
21 Correct 92 ms 660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 560 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 12 ms 512 KB Output is correct
14 Correct 7 ms 592 KB Output is correct
15 Correct 3 ms 592 KB Output is correct
16 Correct 9 ms 848 KB Output is correct
17 Correct 5 ms 592 KB Output is correct
18 Correct 6 ms 628 KB Output is correct
19 Correct 167 ms 560 KB Output is correct
20 Correct 103 ms 568 KB Output is correct
21 Correct 93 ms 564 KB Output is correct
22 Correct 90 ms 580 KB Output is correct
23 Correct 53 ms 564 KB Output is correct
24 Correct 82 ms 668 KB Output is correct
25 Correct 80 ms 676 KB Output is correct
26 Correct 153 ms 664 KB Output is correct
27 Correct 95 ms 664 KB Output is correct
28 Correct 113 ms 668 KB Output is correct
29 Correct 6 ms 336 KB Output is correct
30 Correct 50 ms 636 KB Output is correct
31 Correct 43 ms 668 KB Output is correct
32 Correct 50 ms 844 KB Output is correct
33 Correct 181 ms 592 KB Output is correct
34 Correct 79 ms 592 KB Output is correct
35 Correct 110 ms 672 KB Output is correct
36 Correct 91 ms 592 KB Output is correct
37 Correct 93 ms 664 KB Output is correct
38 Correct 101 ms 592 KB Output is correct
39 Correct 92 ms 660 KB Output is correct
40 Correct 282 ms 2872 KB Output is correct
41 Correct 13 ms 1516 KB Output is correct
42 Correct 130 ms 2884 KB Output is correct
43 Correct 97 ms 2376 KB Output is correct
44 Correct 107 ms 2632 KB Output is correct
45 Correct 344 ms 12140 KB Output is correct
46 Correct 15 ms 5200 KB Output is correct
47 Correct 322 ms 12112 KB Output is correct
48 Correct 136 ms 10312 KB Output is correct
49 Correct 156 ms 10944 KB Output is correct