답안 #1108623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108623 2024-11-04T16:30:09 Z huantran Kamenčići (COCI21_kamencici) C++17
10 / 70
1000 ms 16872 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
const int maxn = 4e2;
const int oo = 1e9 + 7;
const ll inf = 1e18;

int n, k, tol = 0;
int pre[maxn], dp[maxn][maxn][maxn];

int recursive(int l, int r, int m) {
    if (m >= k) {
        dp[l][r][m] = 0;
        return 0;
    }
        
    int h = tol - m - (pre[r] - pre[l - 1]);
    if (h >= k) {
        dp[l][r][m] = 1;
        return 1;
    }

    dp[l][r][m] = (!recursive(l + 1, r, h) | !recursive(l, r - 1, h));
    return dp[l][r][m];
}

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("TASK.inp", "r", stdin);
    //     freopen("TASK.out", "w", stdout);
    // #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);

    cin >> n >> k;
    string s;
    cin >> s;
    s = ' ' + s;
    for (int i = 1; i <= n; i++) {
        pre[i] = pre[i - 1] + (s[i] == 'C');
        if (s[i] == 'C')
            tol++;
    }

    if (recursive(1, n, 0))
        cout << "DA";
    else    
        cout << "NE";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 3 ms 10756 KB Output is correct
3 Correct 1 ms 4432 KB Output is correct
4 Correct 3 ms 12624 KB Output is correct
5 Correct 2 ms 8528 KB Output is correct
6 Correct 2 ms 6480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 3 ms 10756 KB Output is correct
3 Correct 1 ms 4432 KB Output is correct
4 Correct 3 ms 12624 KB Output is correct
5 Correct 2 ms 8528 KB Output is correct
6 Correct 2 ms 6480 KB Output is correct
7 Correct 18 ms 14672 KB Output is correct
8 Correct 11 ms 6480 KB Output is correct
9 Execution timed out 1080 ms 16872 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 3 ms 10756 KB Output is correct
3 Correct 1 ms 4432 KB Output is correct
4 Correct 3 ms 12624 KB Output is correct
5 Correct 2 ms 8528 KB Output is correct
6 Correct 2 ms 6480 KB Output is correct
7 Correct 18 ms 14672 KB Output is correct
8 Correct 11 ms 6480 KB Output is correct
9 Execution timed out 1080 ms 16872 KB Time limit exceeded
10 Halted 0 ms 0 KB -