Submission #656355

# Submission time Handle Problem Language Result Execution time Memory
656355 2022-11-07T03:38:24 Z perchuts Lottery (CEOI18_lot) C++17
80 / 100
493 ms 8012 KB
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define endl '\n'
#define pb push_back
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ii = pair<int,int>;
using iii = tuple<int,int,int>;

const int inf = 2e9+1;
const int mod = 1e9+7;
const int maxn = 1e4+1;

template<typename X, typename Y> bool ckmin(X& x, const Y& y) { return (y < x) ? (x=y,1):0; }
template<typename X, typename Y> bool ckmax(X& x, const Y& y) { return (x < y) ? (x=y,1):0; }

int a[maxn], where[maxn], ans[maxn][101], resp[100];

int main(){_
    int n,l;cin>>n>>l;

    for(int i=1;i<=n;++i)cin>>a[i];    

    int q;cin>>q;

    vector<int>qu(q), ord;

    for(int i=0;i<q;++i)cin>>qu[i], ord.pb(qu[i]);

    sort(all(ord));

    ord.erase(unique(all(ord)),end(ord));

    int i = 0;

    for(int j=0;j<sz(ord);++j)
        while(i!=ord[j])++i, where[i] = j;
    
    while(i!=l)++i, where[i] = q+1;

    for(int i=1;i<=n-l;++i){//distance from two strings
        int x = 1, y = 1 + i, cur = 0;
        for(int j=0;j<l;++j)cur += (a[j+1]!=a[i+j+1]);
        ans[x++][where[cur]]++, ans[y++][where[cur]]++;
        while(y+l-1<=n){
            cur += (a[x+l-1]!=a[y+l-1])-(a[x-1]!=a[y-1]);
            ans[x++][where[cur]]++, ans[y++][where[cur]]++;
        }
    }


    for(int i=1;i<=n-l+1;++i)
        for(int j=1;j<sz(ord);++j)
            ans[i][j] += ans[i][j-1];
    
    for(auto x:qu)
        for(int i=1;i<=n-l+1;++i)cout<<ans[i][where[x]]<<" \n"[i==n-l+1];
    
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 17 ms 1108 KB Output is correct
14 Correct 10 ms 852 KB Output is correct
15 Correct 10 ms 852 KB Output is correct
16 Correct 16 ms 1116 KB Output is correct
17 Correct 15 ms 1012 KB Output is correct
18 Correct 15 ms 1040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 404 ms 4308 KB Output is correct
2 Correct 421 ms 4308 KB Output is correct
3 Correct 413 ms 4308 KB Output is correct
4 Correct 399 ms 4224 KB Output is correct
5 Correct 124 ms 2352 KB Output is correct
6 Correct 364 ms 4032 KB Output is correct
7 Correct 125 ms 2344 KB Output is correct
8 Correct 221 ms 3136 KB Output is correct
9 Correct 389 ms 4180 KB Output is correct
10 Correct 397 ms 4228 KB Output is correct
11 Correct 19 ms 1108 KB Output is correct
12 Correct 205 ms 3104 KB Output is correct
13 Correct 164 ms 2708 KB Output is correct
14 Correct 161 ms 2700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 404 ms 4308 KB Output is correct
2 Correct 421 ms 4308 KB Output is correct
3 Correct 413 ms 4308 KB Output is correct
4 Correct 399 ms 4224 KB Output is correct
5 Correct 124 ms 2352 KB Output is correct
6 Correct 364 ms 4032 KB Output is correct
7 Correct 125 ms 2344 KB Output is correct
8 Correct 221 ms 3136 KB Output is correct
9 Correct 389 ms 4180 KB Output is correct
10 Correct 397 ms 4228 KB Output is correct
11 Correct 19 ms 1108 KB Output is correct
12 Correct 205 ms 3104 KB Output is correct
13 Correct 164 ms 2708 KB Output is correct
14 Correct 161 ms 2700 KB Output is correct
15 Correct 389 ms 4180 KB Output is correct
16 Correct 338 ms 3924 KB Output is correct
17 Correct 410 ms 4308 KB Output is correct
18 Correct 410 ms 4264 KB Output is correct
19 Correct 406 ms 4272 KB Output is correct
20 Correct 413 ms 4260 KB Output is correct
21 Correct 411 ms 4300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 17 ms 1108 KB Output is correct
14 Correct 10 ms 852 KB Output is correct
15 Correct 10 ms 852 KB Output is correct
16 Correct 16 ms 1116 KB Output is correct
17 Correct 15 ms 1012 KB Output is correct
18 Correct 15 ms 1040 KB Output is correct
19 Correct 404 ms 4308 KB Output is correct
20 Correct 421 ms 4308 KB Output is correct
21 Correct 413 ms 4308 KB Output is correct
22 Correct 399 ms 4224 KB Output is correct
23 Correct 124 ms 2352 KB Output is correct
24 Correct 364 ms 4032 KB Output is correct
25 Correct 125 ms 2344 KB Output is correct
26 Correct 221 ms 3136 KB Output is correct
27 Correct 389 ms 4180 KB Output is correct
28 Correct 397 ms 4228 KB Output is correct
29 Correct 19 ms 1108 KB Output is correct
30 Correct 205 ms 3104 KB Output is correct
31 Correct 164 ms 2708 KB Output is correct
32 Correct 161 ms 2700 KB Output is correct
33 Correct 389 ms 4180 KB Output is correct
34 Correct 338 ms 3924 KB Output is correct
35 Correct 410 ms 4308 KB Output is correct
36 Correct 410 ms 4264 KB Output is correct
37 Correct 406 ms 4272 KB Output is correct
38 Correct 413 ms 4260 KB Output is correct
39 Correct 411 ms 4300 KB Output is correct
40 Correct 433 ms 5032 KB Output is correct
41 Correct 13 ms 852 KB Output is correct
42 Correct 419 ms 4940 KB Output is correct
43 Correct 404 ms 4516 KB Output is correct
44 Correct 407 ms 4568 KB Output is correct
45 Correct 493 ms 8012 KB Output is correct
46 Incorrect 19 ms 1236 KB Output isn't correct
47 Halted 0 ms 0 KB -