Submission #950212

# Submission time Handle Problem Language Result Execution time Memory
950212 2024-03-20T06:55:52 Z berr Lottery (CEOI18_lot) C++17
100 / 100
456 ms 8272 KB
#include <bits/stdc++.h>
using namespace std;
//#define int long long
vector<int> ar;
vector<array<int, 2>> qu;

int n, len, q;
int a[(int)1e4][101];
int ind[(int)1e4+1];

void calc(int pos){
    int l=0, r=pos;
    int ans=0;
    if(pos+l-1>=n) return;

    for(int j=0; j+pos<n; j++){
        if(ar[j]!=ar[j+pos]) ans++;
        if(j-len>=0){
            ans-=(ar[j-len]!=ar[j-len+pos]);
        }   
      //  cout<<ans<<"\n";

    
        if(j>=len-1){
            if(ind[ans]==q){
                l++; r++;
                continue;
            }
            a[l][ind[ans]]++;
            a[r][ind[ans]]++;
            l++; r++;
        }

    }
};


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> len;
    ar.resize(n);
    
    for(auto &i: ar) cin >> i;

    cin >> q;
    qu.resize(q);

    for(int i=0; i<q; i++){
        cin >> qu[i][0];
        qu[i][1] = i;
    }

    sort(qu.begin(), qu.end());

    int p=0;
    for(int j=0; j<=n; j++){
        while(p<q&&qu[p][0]< j) p++;
        ind[j]=p;
    }
    
    for(int i=1; i<n; i++){
        calc(i);
    }   
    vector<int> pos(q);

    for(int i=0; i<q; i++){
        pos[qu[i][1]]=i;
    }

    for(int i=0; i<n; i++){
        for(int j=1; j<q; j++){
            a[i][j] += a[i][j-1];
        }

    }
    for(int j=0; j<q; j++){
        for(int i=0; i+len-1<n; i++){
            cout<<a[i][pos[j]]<<" ";
        }
        cout<<"\n";
    }


}   
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 10 ms 2668 KB Output is correct
14 Correct 6 ms 2652 KB Output is correct
15 Correct 5 ms 2652 KB Output is correct
16 Correct 6 ms 2652 KB Output is correct
17 Correct 6 ms 2652 KB Output is correct
18 Correct 6 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 298 ms 4460 KB Output is correct
2 Correct 308 ms 4468 KB Output is correct
3 Correct 145 ms 4468 KB Output is correct
4 Correct 103 ms 3928 KB Output is correct
5 Correct 80 ms 2568 KB Output is correct
6 Correct 105 ms 2948 KB Output is correct
7 Correct 98 ms 2648 KB Output is correct
8 Correct 139 ms 3300 KB Output is correct
9 Correct 114 ms 4216 KB Output is correct
10 Correct 106 ms 4184 KB Output is correct
11 Correct 10 ms 2396 KB Output is correct
12 Correct 81 ms 2740 KB Output is correct
13 Correct 93 ms 2572 KB Output is correct
14 Correct 82 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 298 ms 4460 KB Output is correct
2 Correct 308 ms 4468 KB Output is correct
3 Correct 145 ms 4468 KB Output is correct
4 Correct 103 ms 3928 KB Output is correct
5 Correct 80 ms 2568 KB Output is correct
6 Correct 105 ms 2948 KB Output is correct
7 Correct 98 ms 2648 KB Output is correct
8 Correct 139 ms 3300 KB Output is correct
9 Correct 114 ms 4216 KB Output is correct
10 Correct 106 ms 4184 KB Output is correct
11 Correct 10 ms 2396 KB Output is correct
12 Correct 81 ms 2740 KB Output is correct
13 Correct 93 ms 2572 KB Output is correct
14 Correct 82 ms 2640 KB Output is correct
15 Correct 206 ms 4336 KB Output is correct
16 Correct 99 ms 3300 KB Output is correct
17 Correct 116 ms 4340 KB Output is correct
18 Correct 104 ms 3440 KB Output is correct
19 Correct 104 ms 3408 KB Output is correct
20 Correct 104 ms 4416 KB Output is correct
21 Correct 106 ms 4336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 10 ms 2668 KB Output is correct
14 Correct 6 ms 2652 KB Output is correct
15 Correct 5 ms 2652 KB Output is correct
16 Correct 6 ms 2652 KB Output is correct
17 Correct 6 ms 2652 KB Output is correct
18 Correct 6 ms 2652 KB Output is correct
19 Correct 298 ms 4460 KB Output is correct
20 Correct 308 ms 4468 KB Output is correct
21 Correct 145 ms 4468 KB Output is correct
22 Correct 103 ms 3928 KB Output is correct
23 Correct 80 ms 2568 KB Output is correct
24 Correct 105 ms 2948 KB Output is correct
25 Correct 98 ms 2648 KB Output is correct
26 Correct 139 ms 3300 KB Output is correct
27 Correct 114 ms 4216 KB Output is correct
28 Correct 106 ms 4184 KB Output is correct
29 Correct 10 ms 2396 KB Output is correct
30 Correct 81 ms 2740 KB Output is correct
31 Correct 93 ms 2572 KB Output is correct
32 Correct 82 ms 2640 KB Output is correct
33 Correct 206 ms 4336 KB Output is correct
34 Correct 99 ms 3300 KB Output is correct
35 Correct 116 ms 4340 KB Output is correct
36 Correct 104 ms 3440 KB Output is correct
37 Correct 104 ms 3408 KB Output is correct
38 Correct 104 ms 4416 KB Output is correct
39 Correct 106 ms 4336 KB Output is correct
40 Correct 381 ms 5260 KB Output is correct
41 Correct 53 ms 4512 KB Output is correct
42 Correct 142 ms 5204 KB Output is correct
43 Correct 109 ms 4788 KB Output is correct
44 Correct 127 ms 4800 KB Output is correct
45 Correct 456 ms 8264 KB Output is correct
46 Correct 59 ms 4768 KB Output is correct
47 Correct 279 ms 8272 KB Output is correct
48 Correct 149 ms 6480 KB Output is correct
49 Correct 147 ms 7104 KB Output is correct