Submission #675487

# Submission time Handle Problem Language Result Execution time Memory
675487 2022-12-27T10:41:42 Z Tangirkul Kamenčići (COCI21_kamencici) C++17
30 / 70
2 ms 1364 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;
ll dp[400][400], p[500];

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

void ma1n ()
{
    cin >> n >> k;
    cin >> s;
    for (ll i = 0; i <= n; i++)
    {
        for (ll j = 0; j <= n; j++)
        {
            dp[i][j] = -1;
        }
    }
    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;
} 
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 468 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 0 ms 468 KB Output is correct
10 Correct 0 ms 468 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 2 ms 1364 KB Output is correct
15 Incorrect 1 ms 1364 KB Output isn't correct
16 Halted 0 ms 0 KB -