답안 #86092

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
86092 2018-11-24T19:46:13 Z zubec Lottery (CEOI18_lot) C++14
35 / 100
663 ms 6448 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int n, l, a[20010], dp[110][10010], pos[10010], b[110];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);

    cin >> n >> l;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        a[i+n] = a[i];
    }
    int q;
    cin >> q;
    for (int i = 1; i <= q; i++){
        cin >> b[i];
        pos[b[i]] = i;
    }
    pos[n+1] = q+1;
    for (int i = n; i >= 0; i--){
        if (pos[i] == 0)
            pos[i] = pos[i+1];
    }
    for (int sz = 1; sz <= n; sz++){
        int curans = 0;
        if (l+sz > n)
            break;
        for (int i = 1; i < l; i++){
            if (a[i] != a[i+sz])
                ++curans;
        }
        for (int i = 1; i <= n; i++){
            if (i+l-1+sz > n)
                break;
            if (i != 1 && a[i-1] != a[i+sz-1])
                --curans;
            if (a[i+l-1] != a[i+l-1+sz])
                ++curans;
            //cout << sz << ' ' << i << ' ' << curans << endl;
            ++dp[pos[curans]][i];
            ++dp[pos[curans]][i+sz];
        }
        /*curans = 0;
        for (int i = n-l+1; i <= n; i++){
            if (a[i-sz] != a[i])
                ++curans;
        }
        ++dp[pos[curans]][n-l+1];
        ++dp[pos[curans]][n-l+1-sz];
        for (int i = n-1; i >= 1; i--){
            if (i-l+1-sz <= 0)
                break;
            if (a[i+1] != a[i-sz+1])
                --curans;
            if (a[i-l+1-sz] != a[i-l+1])
                ++curans;
            ++dp[pos[curans]][i-l+1];
            ++dp[pos[curans]][i-l+1-sz];
        }*/
    }
    for (int i = 1; i <= 100; i++){
        for (int j = 1; j <= n; j++)
            dp[i][j] += dp[i-1][j];
    }
    for (int i = 1; i <= q; i++){
        for (int j = 1; j <= n-l+1; j++){
            cout << dp[pos[b[i]]][j] << ' ';
        }
        cout << "\n";
    }

}

/**

100 30
14 12 8 11 3 12 9 1 9 8 1 3 6 11 13 5 3 1 7 7 15 3 2 11 14 8 6 7 8 13 5 16 4 2 13 16 10 10 5 11 7 6 16 3 9 5 9 5 7 15 9 8 11 11 7 16 2 14 4 15 5 16 10 10 5 12 9 2 4 6 1 12 11 11 4 12 4 3 7 10 11 13 2 2 5 5 4 12 3 14 4 7 15 10 15 5 9 1 13 10
20
10
7
1
28
24
26
25
9
13
14
22
29
20
19
5
12
6
0
4
21


*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
2 Incorrect 2 ms 892 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
2 Incorrect 2 ms 892 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 414 ms 4512 KB Output is correct
2 Correct 663 ms 4640 KB Output is correct
3 Correct 244 ms 4696 KB Output is correct
4 Correct 179 ms 4756 KB Output is correct
5 Correct 70 ms 4852 KB Output is correct
6 Correct 171 ms 5212 KB Output is correct
7 Correct 74 ms 5212 KB Output is correct
8 Correct 124 ms 5316 KB Output is correct
9 Correct 213 ms 5404 KB Output is correct
10 Correct 250 ms 5712 KB Output is correct
11 Correct 25 ms 5712 KB Output is correct
12 Correct 172 ms 5712 KB Output is correct
13 Correct 165 ms 5796 KB Output is correct
14 Correct 106 ms 5832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 414 ms 4512 KB Output is correct
2 Correct 663 ms 4640 KB Output is correct
3 Correct 244 ms 4696 KB Output is correct
4 Correct 179 ms 4756 KB Output is correct
5 Correct 70 ms 4852 KB Output is correct
6 Correct 171 ms 5212 KB Output is correct
7 Correct 74 ms 5212 KB Output is correct
8 Correct 124 ms 5316 KB Output is correct
9 Correct 213 ms 5404 KB Output is correct
10 Correct 250 ms 5712 KB Output is correct
11 Correct 25 ms 5712 KB Output is correct
12 Correct 172 ms 5712 KB Output is correct
13 Correct 165 ms 5796 KB Output is correct
14 Correct 106 ms 5832 KB Output is correct
15 Correct 284 ms 5848 KB Output is correct
16 Correct 159 ms 5944 KB Output is correct
17 Correct 207 ms 5996 KB Output is correct
18 Correct 196 ms 6148 KB Output is correct
19 Correct 189 ms 6248 KB Output is correct
20 Correct 185 ms 6348 KB Output is correct
21 Correct 185 ms 6448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
2 Incorrect 2 ms 892 KB Output isn't correct
3 Halted 0 ms 0 KB -