Submission #116174

# Submission time Handle Problem Language Result Execution time Memory
116174 2019-06-11T04:24:34 Z JohnTitor Lottery (CEOI18_lot) C++11
100 / 100
489 ms 8344 KB
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
#define __builtin_popcount __builtin_popcountll
using ll=long long; using ld=long double;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const ld pi=acos(0)*2;
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
#define taskname "Lottery"
int n, l, q;
int a[10001];
int to[10001];
int ans[10001][101];
//int ans[10001];
int r[101];
pair <int, int> k[101];
int main(){
    #ifdef Aria
        if(fopen(taskname".in", "r"))
            freopen(taskname".in", "r", stdin);
    #endif // Aria
    read(n);
    read(l);
    FOR(i, 1, n) read(a[i]);
    read(q);
    FOR(i, 1, q){
        read(k[i].first);
        k[i].second=i;
    }
    sort(k+1, k+q+1);
    DFOR(i, q, 1){
        r[k[i].second]=i;
        FOR(j, 0, k[i].first) to[j]=i;
    }
    FOR(d, 1, n){
        if(d+l>n) break;
        int sum=0;
        FFOR(i, 1, l) sum+=(a[i]!=a[i+d]);
        FOR(i, l, n){
            if(i+d>n) break;
            sum+=(a[i]!=a[i+d]);
//            int sum=0;
//            FFOR(j, 0, l) sum+=a[i-j]!=a[i+d-j];
            ans[i][to[sum]]++;
            ans[i+d][to[sum]]++;
//            if(sum==0) ans[i]++;
//            if(sum==0) ans[i+d]++;
            sum-=(a[i-l+1]!=a[i-l+1+d]);
        }
    }
    FOR(i, 1, n) FOR(j, 2, q) ans[i][j]+=ans[i][j-1];
    sort(k+1, k+q+1, [](pair <int, int> A, pair <int, int> B){
        return A.second<B.second;
    });
    FOR(i, 1, q) FOR(j, l, n) write(ans[j][r[i]]), putchar(" \n"[j==n]);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 14 ms 1152 KB Output is correct
14 Correct 17 ms 1256 KB Output is correct
15 Correct 9 ms 1152 KB Output is correct
16 Correct 13 ms 1276 KB Output is correct
17 Correct 11 ms 1280 KB Output is correct
18 Correct 12 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 411 ms 4356 KB Output is correct
2 Correct 389 ms 4352 KB Output is correct
3 Correct 410 ms 4472 KB Output is correct
4 Correct 380 ms 4344 KB Output is correct
5 Correct 119 ms 2424 KB Output is correct
6 Correct 362 ms 4096 KB Output is correct
7 Correct 118 ms 2304 KB Output is correct
8 Correct 202 ms 3212 KB Output is correct
9 Correct 386 ms 4316 KB Output is correct
10 Correct 393 ms 4344 KB Output is correct
11 Correct 15 ms 1152 KB Output is correct
12 Correct 218 ms 3156 KB Output is correct
13 Correct 159 ms 2776 KB Output is correct
14 Correct 198 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 411 ms 4356 KB Output is correct
2 Correct 389 ms 4352 KB Output is correct
3 Correct 410 ms 4472 KB Output is correct
4 Correct 380 ms 4344 KB Output is correct
5 Correct 119 ms 2424 KB Output is correct
6 Correct 362 ms 4096 KB Output is correct
7 Correct 118 ms 2304 KB Output is correct
8 Correct 202 ms 3212 KB Output is correct
9 Correct 386 ms 4316 KB Output is correct
10 Correct 393 ms 4344 KB Output is correct
11 Correct 15 ms 1152 KB Output is correct
12 Correct 218 ms 3156 KB Output is correct
13 Correct 159 ms 2776 KB Output is correct
14 Correct 198 ms 2688 KB Output is correct
15 Correct 413 ms 4264 KB Output is correct
16 Correct 355 ms 4088 KB Output is correct
17 Correct 489 ms 4460 KB Output is correct
18 Correct 406 ms 4520 KB Output is correct
19 Correct 403 ms 4472 KB Output is correct
20 Correct 405 ms 4420 KB Output is correct
21 Correct 378 ms 4472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 3 ms 512 KB Output is correct
12 Correct 3 ms 512 KB Output is correct
13 Correct 14 ms 1152 KB Output is correct
14 Correct 17 ms 1256 KB Output is correct
15 Correct 9 ms 1152 KB Output is correct
16 Correct 13 ms 1276 KB Output is correct
17 Correct 11 ms 1280 KB Output is correct
18 Correct 12 ms 1280 KB Output is correct
19 Correct 411 ms 4356 KB Output is correct
20 Correct 389 ms 4352 KB Output is correct
21 Correct 410 ms 4472 KB Output is correct
22 Correct 380 ms 4344 KB Output is correct
23 Correct 119 ms 2424 KB Output is correct
24 Correct 362 ms 4096 KB Output is correct
25 Correct 118 ms 2304 KB Output is correct
26 Correct 202 ms 3212 KB Output is correct
27 Correct 386 ms 4316 KB Output is correct
28 Correct 393 ms 4344 KB Output is correct
29 Correct 15 ms 1152 KB Output is correct
30 Correct 218 ms 3156 KB Output is correct
31 Correct 159 ms 2776 KB Output is correct
32 Correct 198 ms 2688 KB Output is correct
33 Correct 413 ms 4264 KB Output is correct
34 Correct 355 ms 4088 KB Output is correct
35 Correct 489 ms 4460 KB Output is correct
36 Correct 406 ms 4520 KB Output is correct
37 Correct 403 ms 4472 KB Output is correct
38 Correct 405 ms 4420 KB Output is correct
39 Correct 378 ms 4472 KB Output is correct
40 Correct 410 ms 5116 KB Output is correct
41 Correct 17 ms 4480 KB Output is correct
42 Correct 439 ms 5212 KB Output is correct
43 Correct 396 ms 4856 KB Output is correct
44 Correct 394 ms 4932 KB Output is correct
45 Correct 485 ms 8184 KB Output is correct
46 Correct 20 ms 4728 KB Output is correct
47 Correct 455 ms 8344 KB Output is correct
48 Correct 392 ms 6520 KB Output is correct
49 Correct 407 ms 7160 KB Output is correct