답안 #675525

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
675525 2022-12-27T11:57:29 Z Tangirkul Kamenčići (COCI21_kamencici) C++17
70 / 70
45 ms 49728 KB
#include<bits/stdc++.h>
  
#define ll long long
#define fi first
#define se second
#define pb push_back
#define sz size
#define Junanna ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  
using namespace std;
  
const ll K = 32;
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;
const ll N = (1e5 + 125);

ll n, k;
string s;
bool dp[400][400][400], used[400][400][400], p[500];

ll rec (ll l, ll r, ll a, ll b)
{
    if (used[l][r][a])
    {
        return dp[l][r][a];
    }
    if (b == k)
    {
        dp[l][r][a] = 1;
        return 1;
    }
    if (a == k)
    {
        dp[l][r][a] = 0;
        return 0;
    }
    used[l][r][a] = 1;
    if ((n - (r - l + 1)) % 2 == 1)
    {
        dp[l][r][a] = min (rec (l + 1, r, a, b + (s[l] == 'C')), rec (l, r - 1, a, b + (s[r] == 'C')));
        return dp[l][r][a];
    }
    else
    {
        dp[l][r][a] = max (rec (l + 1, r, a + (s[l] == 'C'), b), rec (l, r - 1, a + (s[r] == 'C'), b));
        return dp[l][r][a];
    }
}

void ma1n ()
{
    cin >> n >> k;
    cin >> s;
    for (ll i = 0; i < n; i++)
    {
        p[i] = p[i - 1] + (s[i] == 'C');
    }
    if (rec (0, n - 1, 0, 0))
    {
        cout << "DA";
    }
    else
    {
        cout << "NE";
    }
}
    
int main ()
{
    Junanna;
    ll t = 1;
    while (t--)
    {
        ma1n ();
    }
    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 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 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 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 852 KB Output is correct
12 Correct 1 ms 1492 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 340 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 852 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 2 ms 1876 KB Output is correct
14 Correct 43 ms 47648 KB Output is correct
15 Correct 17 ms 15828 KB Output is correct
16 Correct 35 ms 30240 KB Output is correct
17 Correct 45 ms 49728 KB Output is correct
18 Correct 14 ms 20052 KB Output is correct