Submission #1073979

# Submission time Handle Problem Language Result Execution time Memory
1073979 2024-08-25T05:50:07 Z lftroq Lottery (CEOI18_lot) C++14
100 / 100
458 ms 8528 KB
#include <bits/stdc++.h>
#define endl '\n'
#define fi first
#define se second
#define sqrt sqrtl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,pii> piiii;

const int N=1e4+5;
const int Q=105;

int a[N],qu[Q],dp[N][Q],rev[N];

void solve()
{
    int n,l,q;
    cin >> n >> l;
    for(int i=1;i<=n;i++) cin >> a[i];
    cin >> q;
    vector<int> v;
    for(int i=1;i<=q;i++)
    {
        cin >> qu[i];
        v.push_back(qu[i]);
    }
    v.push_back(0);v.push_back(N-1);
    sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
    for(int i=0;i<(int)v.size();i++) rev[v[i]]=i;
    for(int len=1;len<=n-l;len++)
    {
        int x=1,y=len+1,d=0,p=0;
        for(int i=1;i<=l;i++)
        {
            d+=(a[x+i-1]!=a[y+i-1]);
            if(v[p]<d) p++;
        }
//        cout << len << ' ' << d << ":" << endl;
        for(;y<=n-l+1;x++,y++)
        {
            dp[x][p]++;dp[y][p]++;
//            cout << x << ' ' << y << ' ' << d << "   " << p << endl;
            d-=(a[x]!=a[y]);
            if(v[p]>d) p--;
            d+=(a[x+l]!=a[y+l]);
            if(v[p]<d) p++;
        }
//        cout << "=============" << endl;
    }
    for(int i=1;i<=n;i++) for(int j=1;j<(int)v.size();j++) dp[i][j]+=dp[i][j-1];
    for(int i=1;i<=q;i++)
    {
        for(int j=1;j<=n-l+1;j++) cout << dp[j][rev[qu[i]]] << ' ';
        cout << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("hanhhhh.inp","r",stdin);
    //freopen("hanhhhh.out","w",stdout);
    int t=1;
    //cin >> t;
    while(t--) solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 11 ms 1312 KB Output is correct
14 Correct 6 ms 1320 KB Output is correct
15 Correct 6 ms 1372 KB Output is correct
16 Correct 9 ms 1372 KB Output is correct
17 Correct 8 ms 1372 KB Output is correct
18 Correct 8 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 266 ms 4444 KB Output is correct
2 Correct 215 ms 4444 KB Output is correct
3 Correct 207 ms 4632 KB Output is correct
4 Correct 203 ms 4688 KB Output is correct
5 Correct 78 ms 4688 KB Output is correct
6 Correct 185 ms 4656 KB Output is correct
7 Correct 77 ms 4688 KB Output is correct
8 Correct 115 ms 4692 KB Output is correct
9 Correct 194 ms 4692 KB Output is correct
10 Correct 200 ms 4692 KB Output is correct
11 Correct 11 ms 1628 KB Output is correct
12 Correct 115 ms 4176 KB Output is correct
13 Correct 98 ms 4540 KB Output is correct
14 Correct 98 ms 4688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 266 ms 4444 KB Output is correct
2 Correct 215 ms 4444 KB Output is correct
3 Correct 207 ms 4632 KB Output is correct
4 Correct 203 ms 4688 KB Output is correct
5 Correct 78 ms 4688 KB Output is correct
6 Correct 185 ms 4656 KB Output is correct
7 Correct 77 ms 4688 KB Output is correct
8 Correct 115 ms 4692 KB Output is correct
9 Correct 194 ms 4692 KB Output is correct
10 Correct 200 ms 4692 KB Output is correct
11 Correct 11 ms 1628 KB Output is correct
12 Correct 115 ms 4176 KB Output is correct
13 Correct 98 ms 4540 KB Output is correct
14 Correct 98 ms 4688 KB Output is correct
15 Correct 207 ms 4476 KB Output is correct
16 Correct 175 ms 4688 KB Output is correct
17 Correct 211 ms 4696 KB Output is correct
18 Correct 208 ms 4644 KB Output is correct
19 Correct 206 ms 4692 KB Output is correct
20 Correct 200 ms 4688 KB Output is correct
21 Correct 206 ms 4644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 11 ms 1312 KB Output is correct
14 Correct 6 ms 1320 KB Output is correct
15 Correct 6 ms 1372 KB Output is correct
16 Correct 9 ms 1372 KB Output is correct
17 Correct 8 ms 1372 KB Output is correct
18 Correct 8 ms 1260 KB Output is correct
19 Correct 266 ms 4444 KB Output is correct
20 Correct 215 ms 4444 KB Output is correct
21 Correct 207 ms 4632 KB Output is correct
22 Correct 203 ms 4688 KB Output is correct
23 Correct 78 ms 4688 KB Output is correct
24 Correct 185 ms 4656 KB Output is correct
25 Correct 77 ms 4688 KB Output is correct
26 Correct 115 ms 4692 KB Output is correct
27 Correct 194 ms 4692 KB Output is correct
28 Correct 200 ms 4692 KB Output is correct
29 Correct 11 ms 1628 KB Output is correct
30 Correct 115 ms 4176 KB Output is correct
31 Correct 98 ms 4540 KB Output is correct
32 Correct 98 ms 4688 KB Output is correct
33 Correct 207 ms 4476 KB Output is correct
34 Correct 175 ms 4688 KB Output is correct
35 Correct 211 ms 4696 KB Output is correct
36 Correct 208 ms 4644 KB Output is correct
37 Correct 206 ms 4692 KB Output is correct
38 Correct 200 ms 4688 KB Output is correct
39 Correct 206 ms 4644 KB Output is correct
40 Correct 285 ms 5352 KB Output is correct
41 Correct 15 ms 4696 KB Output is correct
42 Correct 211 ms 5204 KB Output is correct
43 Correct 200 ms 5016 KB Output is correct
44 Correct 197 ms 5024 KB Output is correct
45 Correct 458 ms 8276 KB Output is correct
46 Correct 20 ms 4956 KB Output is correct
47 Correct 258 ms 8528 KB Output is correct
48 Correct 240 ms 6560 KB Output is correct
49 Correct 235 ms 7324 KB Output is correct