답안 #579048

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579048 2022-06-18T10:51:20 Z Trisanu_Das Kamenčići (COCI21_kamencici) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define N 351
 
int n, k; string s;
 
int 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] = 0; return;
  }
  if(already_coll >= k){
    dp[l][r][m] = 1; 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 'int main()':
Main.cpp:29:2: error: 'pref' was not declared in this scope
   29 |  pref[0] = (s[0] == 'C');
      |  ^~~~