Language: C++


#include<bits/stdc++.h>
using namespace std;
double prob(double a, double b, double c, n, double (*dp)[bb][cc]) {
	double ret{};
	if (a > 0) {
		//	ret += prob(a - 1, b, c) * transition of (a, b, c) to (a - 1, b, c)
		ret += prob(a - 1, b, c, n, dp) * (a / n);
	}
	if (b > 0) {
		//	ret += prob(a + 1, b - 1, c) * transition of (a, b, c) to (a + 1, b - 1, c)
		ret += prob(a + 1, b - 1, c, n, dp) * (b / n);
	}

	if (c > 0) {
		//	ret += prob(a, b + 1, c - 1) * transition of (a, b, c) to (a, b + 1, c - 1)
		ret += prob(a, b + 1, c - 1, n, dp) * (c / n);
	}
	if (a == 0 && b == 0 && c == 0) {
		return 1;
	}
	return dp[a][b][c] = ret;
}
int main() {
	double n;
	cin >> n;
	vector<int> v(n);
	double aa{}, bb{}, cc{};
	for (int i{}; i < n; i++) {
		cin >> v[i];
		if (v[i] == 1)a++;
		else if (v[i] == 2)b++;
		else c++;
	}
	double dp[a + 1][b + 1][c + 1] {};
	return 1 / prob(a, b, c, n, dp);
}

Compiler output:
a.cc:4:43: error: 'n' has not been declared
    4 | double prob(double a, double b, double c, n, double (*dp)[bb][cc]) {
      |                                           ^
a.cc:4:59: error: 'bb' was not declared in this scope; did you mean 'b'?
    4 | double prob(double a, double b, double c, n, double (*dp)[bb][cc]) {
      |                                                           ^~
      |                                                           b
a.cc:4:63: error: 'cc' was not declared in this scope; did you mean 'c'?
    4 | double prob(double a, double b, double c, n, double (*dp)[bb][cc]) {
      |                                                               ^~
      |                                                               c
a.cc: In function 'double prob(...)':
a.cc:6:13: error: 'a' was not declared in this scope
    6 |         if (a > 0) {
      |             ^
a.cc:8:36: error: 'b' was not declared in this scope
    8 |                 ret += prob(a - 1, b, c, n, dp) * (a / n);
      |                                    ^
a.cc:8:39: error: 'c' was not declared in this scope
    8 |                 ret += prob(a - 1, b, c, n, dp) * (a / n);
      |                                       ^
a.cc:8:42: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |                 ret += prob(a - 1, b, c, n, dp) * (a / n);
      |                                          ^
      |                                          yn
a.cc:8:45: error: 'dp' was not declared in this scope; did you mean 'dup'?
    8 |                 ret += prob(a - 1, b, c, n, dp) * (a / n);
      |                                             ^~
      |                                             dup
a.cc:10:13: error: 'b' was not declared in this scope
   10 |         if (b > 0) {
      |             ^
a.cc:12:29: error: 'a' was not declared in this scope
   12 |                 ret += prob(a + 1, b - 1, c, n, dp) * (b / n);
      |                             ^
a.cc:12:43: error: 'c' was not declared in this scope
   12 |                 ret += prob(a + 1, b - 1, c, n, dp) * (b / n);
      |                                           ^
a.cc:12:46: error: 'n' was not declared in this scope; did you mean 'yn'?
   12 |                 ret += prob(a + 1, b - 1, c, n, dp) * (b / n);
      |                                              ^
      |                                              yn
a.cc:12:49: error: 'dp' was not declared in this scope; did you mean 'dup'?
   12 |                 ret += prob(a + 1, b - 1, c, n, dp) * (b / n);
      |                                                 ^~
      |                                                 dup
a.cc:15:13: error: 'c' was not declared in this scope
   15 |         if (c > 0) {
      |             ^
a.cc:17:29: error: 'a' was not declared in this scope
   17 |                 ret += prob(a, b + 1, c - 1, n, dp) * (c / n);
      |                             ^
a.cc:17:32: error: 'b' was not declared in this scope
   17 |                 ret += prob(a, b + 1, c - 1, n, dp) * (c / n);
      |                                ^
a.cc:17:46: error: 'n' was not declared in this scope; did you mean 'yn'?
   17 |                 ret += prob(a, b + 1, c - 1, n, dp) * (c / n);
      |                                              ^
      |                                              yn
a.cc:17:49: error: 'dp' was not declared in this scope; did you mean 'dup'?
   17 |                 ret += prob(a, b + 1, c - 1, n, dp) * (c / n);
      |                                                 ^~
      |                                                 dup
a.cc:19:13: error: 'a' was not declared in this scope
   19 |         if (a == 0 && b == 0 && c == 0) {
      |             ^
a.cc:19:23: error: 'b' was not declared in this scope
   19 |         if (a == 0 && b == 0 && c == 0) {
      |                       ^
a.cc:19:33: error: 'c' was not declared in this scope
   19 |         if (a == 0 && b == 0 && c == 0) {
      |                                 ^
a.cc:22:16: error: 'dp' was not declared in this scope; did you mean 'dup'?
   22 |         return dp[a][b][c] = ret;
      |                ^~
      |                dup
a.cc:22:19: error: 'a' was not declared in this scope
   22 |         return dp[a][b][c] = ret;
      |                   ^
a.cc:22:22: error: 'b' was not declared in this scope
   22 |         return dp[a][b][c] = ret;
      |                      ^
a.cc:22:25: error: 'c' was not declared in this scope
   22 |         return dp[a][b][c] = ret;
      |                         ^
a.cc: In function 'int main()':
a.cc:31:31: error: 'a' was not declared in this scope
   31 |                 if (v[i] == 1)a++;
      |                               ^
a.cc:32:36: error: 'b' was not declared in this scope
   32 |                 else if (v[i] == 2)b++;
      |                                    ^
a.cc:33:22: error: 'c' was not declared in this scope
   33 |                 else c++;
      |                      ^
a.cc:35:19: error: 'a' was not declared in this scope; did you mean 'aa'?
   35 |         double dp[a + 1][b + 1][c + 1] {};
      |                   ^
      |                   aa
a.cc:35:26: error: 'b' was not declared in this scope; did you mean 'bb'?
   35 |         double dp[a + 1][b + 1][c + 1] {};
      |                          ^
      |                          bb
a.cc:35:33: error: 'c' was not declared in this scope; did you mean 'cc'?
   35 |         double dp[a + 1][b + 1][c + 1] {};
      |                                 ^
      |                                 cc
a.cc:36:37: error: 'dp' was not declared in this scope; did you mean 'dup'?
   36 |         return 1 / prob(a, b, c, n, dp);
      |                                     ^~
      |                                     dup