답안 #926460

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
926460 2024-02-13T04:18:30 Z blackavar Kamenčići (COCI21_kamencici) C++14
70 / 70
218 ms 338752 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long n, f;
    cin >> n >> f;
    string s;
    cin >> s;
    s = ' ' + s;
    long long dp[n + 1][n + 1][n + 1];
    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            for (int k = 0; k <= n; k++)
            {
                dp[i][j][k] = 0;
            }
        }
    }
    long long pref[n + 1];
    pref[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        pref[i] = pref[i - 1] + (s[i] == 'C');
    }
    for (int i = n; i >= 1; i--)
    {
        for (int j = 1; j <= n; j++)
        {
            if (i >= j) continue;
            for (int k = 0; k <= n; k++)
            {
                long long other = pref[n] - (pref[j] - pref[i - 1]) - k;
                if (k >= f) dp[i][j][k] = 0;
                else if (other >= f) dp[i][j][k] = 1;
                else
                {
                    if (!dp[i + 1][j][other] || !dp[i][j - 1][other]) dp[i][j][k] = 1;
                    else dp[i][j][k] = 0;
                }
            }
        }
    }
    if (dp[1][n][0]) cout << "DA";
    else cout << "NE";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 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 460 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 0 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 460 KB Output is correct
7 Correct 1 ms 1368 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1180 KB Output is correct
12 Correct 1 ms 1116 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 0 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 460 KB Output is correct
7 Correct 1 ms 1368 KB Output is correct
8 Correct 1 ms 1116 KB Output is correct
9 Correct 1 ms 1372 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1180 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 218 ms 338752 KB Output is correct
14 Correct 206 ms 335956 KB Output is correct
15 Correct 179 ms 289616 KB Output is correct
16 Correct 198 ms 330328 KB Output is correct
17 Correct 207 ms 333152 KB Output is correct
18 Correct 199 ms 330580 KB Output is correct