답안 #557637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
557637 2022-05-05T16:45:20 Z Vladth11 Lottery (CEOI18_lot) C++14
100 / 100
747 ms 12184 KB
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
 
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long double, pii> muchie;
 
const ll NMAX = 10002;
const ll VMAX = 1001;
const ll INF = (1LL << 60);
const ll MOD = 1000000007;
const ll BLOCK = 447;
const ll base = 31;
const ll nr_of_bits = 15;
 
int v[NMAX];
int f[NMAX];
pii q[NMAX];
int sol[101][NMAX];
int ans[101][NMAX];
 
void update(int x, int y){
    if(f[y] != 0){
        sol[f[y]][x]++;
    }
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int i, n, l, qq;
    cin >> n >> l;
    for(i = 1; i <= n; i++){
        cin >> v[i];
    }
    cin >> qq;
    for(i = 1; i <= qq; i++){
        int x;
        cin >> x;
        q[i] = {x, i};
    }
    sort(q + 1, q + qq + 1);
    for(i = 1; i <= qq; i++){
		if(f[q[i].first] == 0)
        	f[q[i].first] = i;
    }
    for(i = n; i >= 0; i--){
        if(f[i] == 0)
            f[i] = f[i + 1];
    }
    for(int lung = 1; lung <= n - l; lung++){
        int i = 1, j = 1 + lung;
        int cnt = 0;
        for(int t = 1; t <= l; t++){
            if(v[i] != v[j])
                cnt++;
            i++;
            j++;
        }
        update(i - l, cnt);
        update(j - l, cnt);
        int t;
        for(t = 1; t <= n && j <= n; t++){
            if(v[i - l] != v[j - l])
                cnt--;
            if(v[i] != v[j])
                cnt++;
            i++;
            j++;
            update(i - l, cnt);
            update(j - l, cnt);
        }
    }
    for(i = 1; i + l - 1 <= n; i++){
        for(int j = 1; j <= qq; j++){
            sol[j][i] += sol[j - 1][i];
        }
    }
    for(i = 1; i <= qq; i++){
        for(int j = 1; j + l - 1 <= n; j++){
            ans[q[i].second][j] = sol[i][j];
        }
    }
    for(i = 1; i <= qq; i++){
        for(int j = 1; j + l - 1 <= n; j++){
            cout << ans[i][j] << " ";
        }
        cout << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
12 Correct 1 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
12 Correct 1 ms 456 KB Output is correct
13 Correct 13 ms 468 KB Output is correct
14 Correct 8 ms 724 KB Output is correct
15 Correct 5 ms 596 KB Output is correct
16 Correct 7 ms 856 KB Output is correct
17 Correct 6 ms 852 KB Output is correct
18 Correct 6 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 338 ms 436 KB Output is correct
2 Correct 525 ms 460 KB Output is correct
3 Correct 120 ms 436 KB Output is correct
4 Correct 97 ms 436 KB Output is correct
5 Correct 40 ms 408 KB Output is correct
6 Correct 75 ms 428 KB Output is correct
7 Correct 81 ms 416 KB Output is correct
8 Correct 137 ms 428 KB Output is correct
9 Correct 85 ms 436 KB Output is correct
10 Correct 86 ms 448 KB Output is correct
11 Correct 12 ms 340 KB Output is correct
12 Correct 63 ms 392 KB Output is correct
13 Correct 51 ms 460 KB Output is correct
14 Correct 63 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 338 ms 436 KB Output is correct
2 Correct 525 ms 460 KB Output is correct
3 Correct 120 ms 436 KB Output is correct
4 Correct 97 ms 436 KB Output is correct
5 Correct 40 ms 408 KB Output is correct
6 Correct 75 ms 428 KB Output is correct
7 Correct 81 ms 416 KB Output is correct
8 Correct 137 ms 428 KB Output is correct
9 Correct 85 ms 436 KB Output is correct
10 Correct 86 ms 448 KB Output is correct
11 Correct 12 ms 340 KB Output is correct
12 Correct 63 ms 392 KB Output is correct
13 Correct 51 ms 460 KB Output is correct
14 Correct 63 ms 460 KB Output is correct
15 Correct 266 ms 436 KB Output is correct
16 Correct 87 ms 428 KB Output is correct
17 Correct 97 ms 436 KB Output is correct
18 Correct 76 ms 436 KB Output is correct
19 Correct 86 ms 436 KB Output is correct
20 Correct 82 ms 440 KB Output is correct
21 Correct 74 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 456 KB Output is correct
12 Correct 1 ms 456 KB Output is correct
13 Correct 13 ms 468 KB Output is correct
14 Correct 8 ms 724 KB Output is correct
15 Correct 5 ms 596 KB Output is correct
16 Correct 7 ms 856 KB Output is correct
17 Correct 6 ms 852 KB Output is correct
18 Correct 6 ms 852 KB Output is correct
19 Correct 338 ms 436 KB Output is correct
20 Correct 525 ms 460 KB Output is correct
21 Correct 120 ms 436 KB Output is correct
22 Correct 97 ms 436 KB Output is correct
23 Correct 40 ms 408 KB Output is correct
24 Correct 75 ms 428 KB Output is correct
25 Correct 81 ms 416 KB Output is correct
26 Correct 137 ms 428 KB Output is correct
27 Correct 85 ms 436 KB Output is correct
28 Correct 86 ms 448 KB Output is correct
29 Correct 12 ms 340 KB Output is correct
30 Correct 63 ms 392 KB Output is correct
31 Correct 51 ms 460 KB Output is correct
32 Correct 63 ms 460 KB Output is correct
33 Correct 266 ms 436 KB Output is correct
34 Correct 87 ms 428 KB Output is correct
35 Correct 97 ms 436 KB Output is correct
36 Correct 76 ms 436 KB Output is correct
37 Correct 86 ms 436 KB Output is correct
38 Correct 82 ms 440 KB Output is correct
39 Correct 74 ms 448 KB Output is correct
40 Correct 678 ms 2696 KB Output is correct
41 Correct 8 ms 900 KB Output is correct
42 Correct 118 ms 2752 KB Output is correct
43 Correct 83 ms 2432 KB Output is correct
44 Correct 84 ms 2596 KB Output is correct
45 Correct 747 ms 12100 KB Output is correct
46 Correct 20 ms 2380 KB Output is correct
47 Correct 327 ms 12184 KB Output is correct
48 Correct 152 ms 10348 KB Output is correct
49 Correct 140 ms 11008 KB Output is correct