Submission #579047

# Submission time Handle Problem Language Result Execution time Memory
579047 2022-06-18T10:50:36 Z Trisanu_Das Kamenčići (COCI21_kamencici) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define N 351

int n, k; string s;

bool dp[351][351][351], red[351];

void memo(int l, int r, int m){
  if(dp[l][r][m] != -1) return;
  int already_coll = 0;
  if(l != 0) already_coll = red[n - 1] - m - red[r] + red[l - 1];
  else already_coll = red[n - 1] - m - red[r];
  if(m >= k){
    dp[l][r][m] = false; return;
  }
  if(already_coll >= k){
    dp[l][r][m] = true; return
  }
  if(l == r){
	dp[l][r][m] = 0; return;
  }
  memo(l + 1, r, already_coll); memo(l, r - 1, already_coll);
  dp[l][r][m] = (!dp[l + 1][r][already_coll] || !dp[l][r - 1][already_coll]);
}

int main(){
    cin >> n >> k >> s;
	pref[0] = (s[0] == 'C');
	memset(dp, -1, sizeof(dp));
	for(int i = 1; i < n; i++) red[i] = red[i - 1] + (s[i] == 'C');
	memo(0, n - 1, 0);
	if(dp[0][n - 1][0]) cout << "DA\n";
	else cout << "NE\n";
}

Compilation message

Main.cpp: In function 'void memo(int, int, int)':
Main.cpp:10:18: warning: comparison of constant '-1' with boolean expression is always true [-Wbool-compare]
   10 |   if(dp[l][r][m] != -1) return;
      |      ~~~~~~~~~~~~^~~~~
Main.cpp:19:3: error: expected primary-expression before '}' token
   19 |   }
      |   ^
Main.cpp:18:31: error: expected ';' before '}' token
   18 |     dp[l][r][m] = true; return
      |                               ^
      |                               ;
   19 |   }
      |   ~                            
Main.cpp: In function 'int main()':
Main.cpp:29:2: error: 'pref' was not declared in this scope
   29 |  pref[0] = (s[0] == 'C');
      |  ^~~~