Submission #666381

# Submission time Handle Problem Language Result Execution time Memory
666381 2022-11-28T11:29:23 Z ktkerem Lottery (CEOI18_lot) C++17
100 / 100
1086 ms 8356 KB
/*#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
#include<bits/stdc++.h>
/**/
typedef int ll;
//typedef long long ll;
typedef unsigned long long ull;
typedef std::string str;
/*typedef __int128 vll;
typedef unsigned __int128 uvll;*/
#define llll std::pair<ll , ll>
#define pb push_back
#define pf push_front
#define halo cout << "hello\n"
#define fi first
#define sec second
#define all(a) a.begin() , a.end()
const ll limit = 1e9+7; 
const ll ous = 1e5 + 7;
const ll dx[4] = {-1 , 0 , 1 , 0} , dy[4] = {0,1,0,-1};
ll n , m;std::vector<ll> ar;
void solve(){
    std::cin >> n >> m;
    ar.resize(n);
    for(ll i = 0;n>i;i++){
        std::cin >> ar[i];    
    }
    ll q;std::cin >> q;
    ll ans[q+5][n - m + 10];
    memset(ans , 0 , sizeof(ans));
    std::vector<llll> que;
    que.pb({limit , limit});
    for(ll i = 0;q>i;i++){
        ll x;std::cin >> x;
        que.pb({x , i});
    }
    std::sort(all(que));
    for(ll i = 1;n - m>=i;i++){
        ll cst = 0;
        for(ll j = 0;m>j;j++){
            cst += (ar[j] != ar[i + j]);
        }
        llll y = {cst , -limit};
        ll o = std::lower_bound(all(que) , y) - que.begin();
        if(que[o].sec != limit){
            ans[que[o].sec][0]++;
            ans[que[o].sec][i]++;
        }
        for(ll j = m;n>j+i;j++){
            cst -= (ar[j - m] != ar[j-m+i]);
            cst += (ar[j] != ar[j + i]);
            y = {cst , -limit};
            o = std::lower_bound(all(que) , y) - que.begin();
            if(que[o].sec != limit){
                ans[que[o].sec][j - m + 1]++;
                ans[que[o].sec][i + j - m + 1]++;
            }
        }
    }
    for(ll i =1;q>i;i++){
        for(ll j =0;n-m+1>j;j++){
            ans[que[i].sec][j] += ans[que[i-1].sec][j]; 
        }
    }
    for(ll i =0;q>i;i++){
        for(ll j =0;n-m+1>j;j++){
            std::cout << ans[i][j] << " ";
        }
        std::cout << "\n";
    }
    return;/**/
}
signed main(){
    ll t=1;
    //std::cin >> t;
    ll o = 1;
    while(t--){ 
        //cout << "Case " << o++ << ":\n";
        solve();
    }
    return 0;
}/**/

Compilation message

lot.cpp:5:78: warning: "/*" within comment [-Wcomment]
    5 | #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")/**/
      |                                                                               
lot.cpp: In function 'int main()':
lot.cpp:79:8: warning: unused variable 'o' [-Wunused-variable]
   79 |     ll o = 1;
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 21 ms 380 KB Output is correct
14 Correct 12 ms 468 KB Output is correct
15 Correct 8 ms 340 KB Output is correct
16 Correct 14 ms 488 KB Output is correct
17 Correct 12 ms 468 KB Output is correct
18 Correct 13 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 367 ms 544 KB Output is correct
2 Correct 272 ms 568 KB Output is correct
3 Correct 225 ms 584 KB Output is correct
4 Correct 225 ms 644 KB Output is correct
5 Correct 73 ms 544 KB Output is correct
6 Correct 204 ms 644 KB Output is correct
7 Correct 105 ms 528 KB Output is correct
8 Correct 182 ms 580 KB Output is correct
9 Correct 217 ms 632 KB Output is correct
10 Correct 231 ms 636 KB Output is correct
11 Correct 10 ms 364 KB Output is correct
12 Correct 113 ms 560 KB Output is correct
13 Correct 97 ms 564 KB Output is correct
14 Correct 99 ms 548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 367 ms 544 KB Output is correct
2 Correct 272 ms 568 KB Output is correct
3 Correct 225 ms 584 KB Output is correct
4 Correct 225 ms 644 KB Output is correct
5 Correct 73 ms 544 KB Output is correct
6 Correct 204 ms 644 KB Output is correct
7 Correct 105 ms 528 KB Output is correct
8 Correct 182 ms 580 KB Output is correct
9 Correct 217 ms 632 KB Output is correct
10 Correct 231 ms 636 KB Output is correct
11 Correct 10 ms 364 KB Output is correct
12 Correct 113 ms 560 KB Output is correct
13 Correct 97 ms 564 KB Output is correct
14 Correct 99 ms 548 KB Output is correct
15 Correct 288 ms 572 KB Output is correct
16 Correct 195 ms 624 KB Output is correct
17 Correct 267 ms 684 KB Output is correct
18 Correct 233 ms 644 KB Output is correct
19 Correct 230 ms 644 KB Output is correct
20 Correct 234 ms 648 KB Output is correct
21 Correct 207 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 300 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 21 ms 380 KB Output is correct
14 Correct 12 ms 468 KB Output is correct
15 Correct 8 ms 340 KB Output is correct
16 Correct 14 ms 488 KB Output is correct
17 Correct 12 ms 468 KB Output is correct
18 Correct 13 ms 468 KB Output is correct
19 Correct 367 ms 544 KB Output is correct
20 Correct 272 ms 568 KB Output is correct
21 Correct 225 ms 584 KB Output is correct
22 Correct 225 ms 644 KB Output is correct
23 Correct 73 ms 544 KB Output is correct
24 Correct 204 ms 644 KB Output is correct
25 Correct 105 ms 528 KB Output is correct
26 Correct 182 ms 580 KB Output is correct
27 Correct 217 ms 632 KB Output is correct
28 Correct 231 ms 636 KB Output is correct
29 Correct 10 ms 364 KB Output is correct
30 Correct 113 ms 560 KB Output is correct
31 Correct 97 ms 564 KB Output is correct
32 Correct 99 ms 548 KB Output is correct
33 Correct 288 ms 572 KB Output is correct
34 Correct 195 ms 624 KB Output is correct
35 Correct 267 ms 684 KB Output is correct
36 Correct 233 ms 644 KB Output is correct
37 Correct 230 ms 644 KB Output is correct
38 Correct 234 ms 648 KB Output is correct
39 Correct 207 ms 644 KB Output is correct
40 Correct 645 ms 2068 KB Output is correct
41 Correct 15 ms 596 KB Output is correct
42 Correct 334 ms 2080 KB Output is correct
43 Correct 314 ms 1736 KB Output is correct
44 Correct 307 ms 1856 KB Output is correct
45 Correct 1086 ms 8244 KB Output is correct
46 Correct 29 ms 1124 KB Output is correct
47 Correct 605 ms 8356 KB Output is correct
48 Correct 466 ms 6364 KB Output is correct
49 Correct 457 ms 7044 KB Output is correct