Submission #869539

# Submission time Handle Problem Language Result Execution time Memory
869539 2023-11-04T16:41:53 Z JoksimKaktus Kamenčići (COCI21_kamencici) C++17
70 / 70
38 ms 183124 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int dp [360][360][360];
int pre[360];
int n,k;
string s;

bool find(int l,int r,int m){
    if(dp[l][r][m] != -1)return dp[l][r][m];
    int h = pre[n] - m - (pre[r]-pre[l-1]);
    if(m >= k){
        return dp[l][r][m] = false;
    }else if(h >= k){
        return dp[l][r][m] = true;
    }else{
        return dp[l][r][m] = !find(l+1,r,h) || !find(l,r-1,h);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    cin >> n >> k >> s;
    pre[0]=0;
    s = " " + s;
    for(int i = 1;i <= n;i++){
        pre[i]=pre[i-1] + (s[i] == 'C');
    }
    memset(dp,-1,sizeof dp);
    bool da = find(1,n,0);
    da ? cout << "DA" : cout << "NE";
    return 0;
}

Compilation message

Main.cpp: In function 'bool find(int, int, int)':
Main.cpp:15:28: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   15 |         return dp[l][r][m] = false;
      |                ~~~~~~~~~~~~^~~~~~~
Main.cpp:17:28: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   17 |         return dp[l][r][m] = true;
      |                ~~~~~~~~~~~~^~~~~~
Main.cpp:19:28: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   19 |         return dp[l][r][m] = !find(l+1,r,h) || !find(l,r-1,h);
      |                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 26 ms 182912 KB Output is correct
2 Correct 21 ms 182848 KB Output is correct
3 Correct 22 ms 182916 KB Output is correct
4 Correct 20 ms 182876 KB Output is correct
5 Correct 21 ms 182868 KB Output is correct
6 Correct 21 ms 182876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 182912 KB Output is correct
2 Correct 21 ms 182848 KB Output is correct
3 Correct 22 ms 182916 KB Output is correct
4 Correct 20 ms 182876 KB Output is correct
5 Correct 21 ms 182868 KB Output is correct
6 Correct 21 ms 182876 KB Output is correct
7 Correct 22 ms 182876 KB Output is correct
8 Correct 21 ms 182868 KB Output is correct
9 Correct 22 ms 182876 KB Output is correct
10 Correct 21 ms 182968 KB Output is correct
11 Correct 21 ms 182832 KB Output is correct
12 Correct 21 ms 182816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 182912 KB Output is correct
2 Correct 21 ms 182848 KB Output is correct
3 Correct 22 ms 182916 KB Output is correct
4 Correct 20 ms 182876 KB Output is correct
5 Correct 21 ms 182868 KB Output is correct
6 Correct 21 ms 182876 KB Output is correct
7 Correct 22 ms 182876 KB Output is correct
8 Correct 21 ms 182868 KB Output is correct
9 Correct 22 ms 182876 KB Output is correct
10 Correct 21 ms 182968 KB Output is correct
11 Correct 21 ms 182832 KB Output is correct
12 Correct 21 ms 182816 KB Output is correct
13 Correct 21 ms 182876 KB Output is correct
14 Correct 38 ms 183124 KB Output is correct
15 Correct 25 ms 182876 KB Output is correct
16 Correct 29 ms 182888 KB Output is correct
17 Correct 24 ms 182876 KB Output is correct
18 Correct 23 ms 182876 KB Output is correct