Submission #598563

# Submission time Handle Problem Language Result Execution time Memory
598563 2022-07-18T14:03:00 Z jiahng Lottery (CEOI18_lot) C++14
100 / 100
864 ms 8264 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define ll int
typedef pair<int,int> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define FOR(i,s,e) for(int i=s;i<=int(e);++i)
#define DEC(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 10010
#define INF (ll)(1e9+10)
#define MOD 1000000007
typedef pair <vi, int> pvi;
typedef pair <int,pi> ipi;
typedef vector <pii> vpii;
typedef pair <pi,pi> pipi;
int N,L,A[maxn];
int Q,k;
int B[105];
map <int,int> C;
int num[105][maxn], ans[105][maxn];
int32_t main(){
    fast;
    cin >> N >> L;
    FOR(i,1,N) cin >> A[i];
    cin >> Q;
    vi v;
    FOR(i,1,Q){
        cin >> B[i]; v.pb(B[i]);
    }
    sort(all(v)); v.erase(unique(all(v)), v.end());
    FOR(i,2,N+1-L){
       int cur = 0;
       FOR(j,1,L) cur += (A[j] != A[i+j-1]);
       FOR(j,0,N+1-L-i){
            int k = lbd(v, cur) - v.begin();
            num[k][j+1]++, num[k][i+j]++;
            //cout << i+j << ' ' << j+1  << ' ' << cur << '\n';
            cur -= A[j+1] != A[j+i];
            cur += A[j+1+L] != A[j+i+L];
        }
    }
    FOR(i,1,v.size()-1) FOR(j,1,N) num[i][j] += num[i-1][j];
    FOR(i,1,Q){
        int k = lbd(v, B[i]) - v.begin();
        FOR(j,1,N-L+1) cout << num[k][j] << ' ';
        cout << '\n';
    }
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 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 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 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 16 ms 412 KB Output is correct
14 Correct 9 ms 596 KB Output is correct
15 Correct 9 ms 468 KB Output is correct
16 Correct 16 ms 692 KB Output is correct
17 Correct 15 ms 672 KB Output is correct
18 Correct 14 ms 560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 302 ms 436 KB Output is correct
2 Correct 229 ms 432 KB Output is correct
3 Correct 214 ms 460 KB Output is correct
4 Correct 209 ms 432 KB Output is correct
5 Correct 84 ms 376 KB Output is correct
6 Correct 191 ms 412 KB Output is correct
7 Correct 70 ms 372 KB Output is correct
8 Correct 112 ms 396 KB Output is correct
9 Correct 237 ms 432 KB Output is correct
10 Correct 215 ms 548 KB Output is correct
11 Correct 11 ms 340 KB Output is correct
12 Correct 120 ms 604 KB Output is correct
13 Correct 115 ms 492 KB Output is correct
14 Correct 95 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 302 ms 436 KB Output is correct
2 Correct 229 ms 432 KB Output is correct
3 Correct 214 ms 460 KB Output is correct
4 Correct 209 ms 432 KB Output is correct
5 Correct 84 ms 376 KB Output is correct
6 Correct 191 ms 412 KB Output is correct
7 Correct 70 ms 372 KB Output is correct
8 Correct 112 ms 396 KB Output is correct
9 Correct 237 ms 432 KB Output is correct
10 Correct 215 ms 548 KB Output is correct
11 Correct 11 ms 340 KB Output is correct
12 Correct 120 ms 604 KB Output is correct
13 Correct 115 ms 492 KB Output is correct
14 Correct 95 ms 500 KB Output is correct
15 Correct 203 ms 468 KB Output is correct
16 Correct 186 ms 588 KB Output is correct
17 Correct 225 ms 544 KB Output is correct
18 Correct 214 ms 520 KB Output is correct
19 Correct 223 ms 532 KB Output is correct
20 Correct 224 ms 468 KB Output is correct
21 Correct 213 ms 536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 332 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 16 ms 412 KB Output is correct
14 Correct 9 ms 596 KB Output is correct
15 Correct 9 ms 468 KB Output is correct
16 Correct 16 ms 692 KB Output is correct
17 Correct 15 ms 672 KB Output is correct
18 Correct 14 ms 560 KB Output is correct
19 Correct 302 ms 436 KB Output is correct
20 Correct 229 ms 432 KB Output is correct
21 Correct 214 ms 460 KB Output is correct
22 Correct 209 ms 432 KB Output is correct
23 Correct 84 ms 376 KB Output is correct
24 Correct 191 ms 412 KB Output is correct
25 Correct 70 ms 372 KB Output is correct
26 Correct 112 ms 396 KB Output is correct
27 Correct 237 ms 432 KB Output is correct
28 Correct 215 ms 548 KB Output is correct
29 Correct 11 ms 340 KB Output is correct
30 Correct 120 ms 604 KB Output is correct
31 Correct 115 ms 492 KB Output is correct
32 Correct 95 ms 500 KB Output is correct
33 Correct 203 ms 468 KB Output is correct
34 Correct 186 ms 588 KB Output is correct
35 Correct 225 ms 544 KB Output is correct
36 Correct 214 ms 520 KB Output is correct
37 Correct 223 ms 532 KB Output is correct
38 Correct 224 ms 468 KB Output is correct
39 Correct 213 ms 536 KB Output is correct
40 Correct 438 ms 1880 KB Output is correct
41 Correct 13 ms 1264 KB Output is correct
42 Correct 365 ms 1972 KB Output is correct
43 Correct 343 ms 1656 KB Output is correct
44 Correct 348 ms 1784 KB Output is correct
45 Correct 864 ms 8116 KB Output is correct
46 Correct 21 ms 4668 KB Output is correct
47 Correct 587 ms 8264 KB Output is correct
48 Correct 498 ms 5988 KB Output is correct
49 Correct 502 ms 6788 KB Output is correct