답안 #930092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
930092 2024-02-18T13:04:27 Z Mohammadamin__Sh Lottery (CEOI18_lot) C++17
100 / 100
1063 ms 12504 KB
//In His Name
#include <bits/stdc++.h>
//#pragma GCC optimization("O2")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
using namespace std;
#define ll long long
#define int ll
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
#define bug(x) cout << "Ah shit , here we go again : " << x <<endl
#define all(x) x.begin() , x.end()
const int maxn = 1e4 + 10, MOD = 1e9 + 7;
const ll INF = 1e18;

int n , l , a[maxn] , q , dp[maxn][105];
vector<int> query , allq;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n >> l;
    for(int i = 1 ; i <= n ; i++) cin >> a[i];
    cin >> q;
    for(int i = 1 ; i <= q ; i++){
        int x;
        cin >> x;
        query.pb(x) , allq.pb(x);
    }
    sort(all(query));
    query.resize(unique(all(query)) - query.begin());
    for(int i = 1 ; i <= n-l ; i++) {
        int w = 0;
        for(int k = 1 ; k <= l ; k++) if(a[i+k] == a[k]) w++;
        int idx = lower_bound(all(query) , l - w) - query.begin() + 1 ;
        dp[i+1][idx]++ , dp[1][idx]++;
        for(int k = 2 ; k+i <= n-l+1 ; k++){
            if(a[k+l-1] == a[i+k+l-1]) w++;
            if(a[k-1] == a[i+k-1]) w--;
            idx = lower_bound(all(query) , (l - w)) - query.begin() + 1 ;
            dp[k][idx]++ , dp[i+k][idx]++;
        }
    }
    for(int i = 1 ; i <= n-l+1 ; i++) for(int j = 1 ; j <= q ; j++) dp[i][j] += dp[i][j-1];
    for(int j = 0 ; j < q ; j++){
        int x = allq[j];
        int idx = lower_bound(all(query) , x) - query.begin() + 1 ;
        for(int i = 1 ; i <= n-l+1 ; i++) cout << dp[i][idx] << " ";
        cout << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 2904 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 2904 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
13 Correct 13 ms 2712 KB Output is correct
14 Correct 8 ms 2652 KB Output is correct
15 Correct 7 ms 2648 KB Output is correct
16 Correct 14 ms 2712 KB Output is correct
17 Correct 12 ms 2652 KB Output is correct
18 Correct 12 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 441 ms 8788 KB Output is correct
2 Correct 605 ms 8540 KB Output is correct
3 Correct 244 ms 8732 KB Output is correct
4 Correct 214 ms 8568 KB Output is correct
5 Correct 65 ms 4808 KB Output is correct
6 Correct 177 ms 8028 KB Output is correct
7 Correct 62 ms 4944 KB Output is correct
8 Correct 103 ms 6748 KB Output is correct
9 Correct 194 ms 8476 KB Output is correct
10 Correct 200 ms 8568 KB Output is correct
11 Correct 12 ms 2648 KB Output is correct
12 Correct 129 ms 6864 KB Output is correct
13 Correct 88 ms 6748 KB Output is correct
14 Correct 89 ms 6856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 441 ms 8788 KB Output is correct
2 Correct 605 ms 8540 KB Output is correct
3 Correct 244 ms 8732 KB Output is correct
4 Correct 214 ms 8568 KB Output is correct
5 Correct 65 ms 4808 KB Output is correct
6 Correct 177 ms 8028 KB Output is correct
7 Correct 62 ms 4944 KB Output is correct
8 Correct 103 ms 6748 KB Output is correct
9 Correct 194 ms 8476 KB Output is correct
10 Correct 200 ms 8568 KB Output is correct
11 Correct 12 ms 2648 KB Output is correct
12 Correct 129 ms 6864 KB Output is correct
13 Correct 88 ms 6748 KB Output is correct
14 Correct 89 ms 6856 KB Output is correct
15 Correct 278 ms 8460 KB Output is correct
16 Correct 165 ms 7772 KB Output is correct
17 Correct 221 ms 8540 KB Output is correct
18 Correct 212 ms 8640 KB Output is correct
19 Correct 208 ms 8648 KB Output is correct
20 Correct 204 ms 8660 KB Output is correct
21 Correct 213 ms 8664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 1 ms 2904 KB Output is correct
11 Correct 1 ms 2652 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
13 Correct 13 ms 2712 KB Output is correct
14 Correct 8 ms 2652 KB Output is correct
15 Correct 7 ms 2648 KB Output is correct
16 Correct 14 ms 2712 KB Output is correct
17 Correct 12 ms 2652 KB Output is correct
18 Correct 12 ms 2652 KB Output is correct
19 Correct 441 ms 8788 KB Output is correct
20 Correct 605 ms 8540 KB Output is correct
21 Correct 244 ms 8732 KB Output is correct
22 Correct 214 ms 8568 KB Output is correct
23 Correct 65 ms 4808 KB Output is correct
24 Correct 177 ms 8028 KB Output is correct
25 Correct 62 ms 4944 KB Output is correct
26 Correct 103 ms 6748 KB Output is correct
27 Correct 194 ms 8476 KB Output is correct
28 Correct 200 ms 8568 KB Output is correct
29 Correct 12 ms 2648 KB Output is correct
30 Correct 129 ms 6864 KB Output is correct
31 Correct 88 ms 6748 KB Output is correct
32 Correct 89 ms 6856 KB Output is correct
33 Correct 278 ms 8460 KB Output is correct
34 Correct 165 ms 7772 KB Output is correct
35 Correct 221 ms 8540 KB Output is correct
36 Correct 212 ms 8640 KB Output is correct
37 Correct 208 ms 8648 KB Output is correct
38 Correct 204 ms 8660 KB Output is correct
39 Correct 213 ms 8664 KB Output is correct
40 Correct 852 ms 9420 KB Output is correct
41 Correct 11 ms 2648 KB Output is correct
42 Correct 366 ms 9416 KB Output is correct
43 Correct 309 ms 8788 KB Output is correct
44 Correct 302 ms 8880 KB Output is correct
45 Correct 1063 ms 12496 KB Output is correct
46 Correct 23 ms 3164 KB Output is correct
47 Correct 556 ms 12504 KB Output is correct
48 Correct 421 ms 10528 KB Output is correct
49 Correct 429 ms 11252 KB Output is correct