답안 #715032

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
715032 2023-03-25T21:08:58 Z keystone Kamenčići (COCI21_kamencici) C++14
70 / 70
104 ms 175364 KB
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    vector<int> pre(n + 1);
    for (int i = 1; i <= n; i++) {
        pre[i] = pre[i - 1] + (s[i - 1] == 'C');
    }

    vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(n + 1, vector<int>(pre[n] + 1)));

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= pre[n]; j++) {
            dp[i][i][j] = (j + (s[i - 1] == 'C') >= k) ? 0 : 1;
        }
    }

    for (int i = 2; i <= n; i++) {
        for (int j = 1; j + i - 1 <= n; j++) {
            for (int l = 0; l <= pre[n] - (pre[j + i - 1] - pre[j - 1]); l++) {
                int bcnt = pre[n] - (pre[j + i - 1] - pre[j - 1]) - l;
                dp[j][j + i - 1][l] = (l >= k) ? 0 : (bcnt >= k) ? 1 : (dp[j + 1][j + i - 1][bcnt] && dp[j][j + i - 2][bcnt]) ? 0 : 1;
            }
        }
    }

    cout << (dp[1][n][0] ? "DA\n" : "NE\n");

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 576 KB Output is correct
11 Correct 1 ms 724 KB Output is correct
12 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 576 KB Output is correct
11 Correct 1 ms 724 KB Output is correct
12 Correct 1 ms 724 KB Output is correct
13 Correct 97 ms 175364 KB Output is correct
14 Correct 42 ms 43604 KB Output is correct
15 Correct 28 ms 34204 KB Output is correct
16 Correct 104 ms 132452 KB Output is correct
17 Correct 103 ms 167628 KB Output is correct
18 Correct 90 ms 164756 KB Output is correct