Submission #862118

# Submission time Handle Problem Language Result Execution time Memory
862118 2023-10-17T14:20:15 Z Youssif_Elkadi Kamenčići (COCI21_kamencici) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
const long long N = 351, mod = 1e9 + 7, base = 31;
int dp[N][N][N][2];
int n, k;
int pref[N];
string x;
int solve(int l, int r, int rem1, int t)
{
    int rem2;
    if (rem1 == 0)
        return 0;
    if (rem2 == 0)
        return 1;
    if (~dp[l][r][rem1][t])
        return dp[l][r][rem1][t];
    if (t)
        return dp[l][r][rem1][rem2][t] = min(solve(l + 1, r, rem1, rem2 - (x[l] == 'C'), 0), solve(l, r - 1, rem1, rem2 - (x[r] == 'C'), 0));
    else
        return dp[l][r][rem1][rem2][t] = max(solve(l + 1, r, rem1 - (x[l] == 'C'), rem2, 1), solve(l, r - 1, rem1 - (x[r] == 'C'), rem2, 1));
}
int main()
{
    memset(dp, -1, sizeof dp);
    cin >> n >> k;
    cin >> x;
    for (int i = 0; i < n; i++)
    {
        pref[i] = (x[i] == 'C');
        if (i)
            pref[i] += pref[i - 1];
    }
    cout << (solve(0, n - 1, k, 0) ? "DA" : "NE");
}

Compilation message

Main.cpp: In function 'int solve(int, int, int, int)':
Main.cpp:18:36: error: invalid types 'int[int]' for array subscript
   18 |         return dp[l][r][rem1][rem2][t] = min(solve(l + 1, r, rem1, rem2 - (x[l] == 'C'), 0), solve(l, r - 1, rem1, rem2 - (x[r] == 'C'), 0));
      |                                    ^
Main.cpp:18:91: error: too many arguments to function 'int solve(int, int, int, int)'
   18 |         return dp[l][r][rem1][rem2][t] = min(solve(l + 1, r, rem1, rem2 - (x[l] == 'C'), 0), solve(l, r - 1, rem1, rem2 - (x[r] == 'C'), 0));
      |                                                                                           ^
Main.cpp:8:5: note: declared here
    8 | int solve(int l, int r, int rem1, int t)
      |     ^~~~~
Main.cpp:18:139: error: too many arguments to function 'int solve(int, int, int, int)'
   18 |         return dp[l][r][rem1][rem2][t] = min(solve(l + 1, r, rem1, rem2 - (x[l] == 'C'), 0), solve(l, r - 1, rem1, rem2 - (x[r] == 'C'), 0));
      |                                                                                                                                           ^
Main.cpp:8:5: note: declared here
    8 | int solve(int l, int r, int rem1, int t)
      |     ^~~~~
Main.cpp:20:36: error: invalid types 'int[int]' for array subscript
   20 |         return dp[l][r][rem1][rem2][t] = max(solve(l + 1, r, rem1 - (x[l] == 'C'), rem2, 1), solve(l, r - 1, rem1 - (x[r] == 'C'), rem2, 1));
      |                                    ^
Main.cpp:20:91: error: too many arguments to function 'int solve(int, int, int, int)'
   20 |         return dp[l][r][rem1][rem2][t] = max(solve(l + 1, r, rem1 - (x[l] == 'C'), rem2, 1), solve(l, r - 1, rem1 - (x[r] == 'C'), rem2, 1));
      |                                                                                           ^
Main.cpp:8:5: note: declared here
    8 | int solve(int l, int r, int rem1, int t)
      |     ^~~~~
Main.cpp:20:139: error: too many arguments to function 'int solve(int, int, int, int)'
   20 |         return dp[l][r][rem1][rem2][t] = max(solve(l + 1, r, rem1 - (x[l] == 'C'), rem2, 1), solve(l, r - 1, rem1 - (x[r] == 'C'), rem2, 1));
      |                                                                                                                                           ^
Main.cpp:8:5: note: declared here
    8 | int solve(int l, int r, int rem1, int t)
      |     ^~~~~