Language: C++

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 105
#define ll long long
using namespace std;
ll dp[2 * maxn][maxn][maxn];
ll pw[maxn][maxn * maxn];
ll jc[maxn], bjc[maxn];
ll mod;

ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
ll cal(int x, int y, int i, int j, int k) {
	ll dv = bjc[x - j] * bjc[y - k] % mod;
	int nr = (i + 1) / 2, sq = x * y - j * k;
	dv = dv * pw[nr][sq] % mod;
	if (i % 2 == 1) 
		dv = dv * pw[c + 1 - nr][sq] % mod;
	else {
		dv = dv * pw[c - nr][sq] % mod;
		if ((x + y - (j + k)) % 2 == 1) dv *= -1;
	}
	return dv;
}
int main()
{
	int n, m, c;
	cin >> n >> m >> c >> mod;
	jc[0] = bjc[0] = 1;
	for (int i = 1; i < maxn; i++)
		jc[i] = jc[i - 1] * i % mod, 
		bjc[i] = ksm(jc[i], mod - 2);
	for (int i = 0; i < maxn; i++) {
		pw[i][0] = 1;
		for (int j = 1; j < maxn * maxn; j++)
			pw[i][j] = pw[i][j - 1] * i % mod;
	}
	for (int i = 0; i <= 2 * k + 1; i++)
	{
		int ns = (i + 1) / 2;
		for (int x = 0; x <= n; x++)
			for (int y = 0; y <= m; y++) {
				if (i == 0) {
					if (j == n && k == m) dp[i][j][k] = 1;
					else dp[i][j][k] = 0;
				}
				else {
					for (int j = x; j >= 0; j--)
						for (int k = y; k >= 0; k--) {
							dp[i][x][y] += cal (x, y, i, j, k) * dp[i - 1][j][k];
							dp[i][x][y] %= mod;
						}
				}
			}
		for (int x = 0; x <= n; x++)
			for (int j = x; j >= 0; j--)
				for (int k = 0; k <= m; k++) {
					ll nr = cal(x, k, i, j, k);
					for (int y = k; y <= m; y++) {
						ll ns = nr * pw[ns][x * (y - k)] % mod * pw[c - ns][x * (y - k)] % mod * bjc[y - k] % mod;
						if ((y - k) & 1) ns *= -1;
						dp[i][x][y] += ns * dp[i - 1][j][k];
						dp[i][x][y] %= mod;
					}
				}
		for (int y = 0; y <= m; y++) {
			for (int k = y; k >= 0; k--)
				for (int j = 0; j <= n; j++) {
					for (int x = j; x <= )
		//i cant finish it
		}
	}
	ll ans = dp[1][0][0];
	ans = ans * jc[n] % mod * jc[m] % mod;
	if (ans < 0) ans += mod;
	cout << ans << endl;
	return 0;
}
/*
1 2 2 107
*/

Compiler output:
a.cc: In function 'long long int cal(int, int, int, int, int)':
a.cc:26:30: error: 'c' was not declared in this scope
   26 |                 dv = dv * pw[c + 1 - nr][sq] % mod;
      |                              ^
a.cc:28:30: error: 'c' was not declared in this scope
   28 |                 dv = dv * pw[c - nr][sq] % mod;
      |                              ^
a.cc: In function 'int main()':
a.cc:46:34: error: 'k' was not declared in this scope
   46 |         for (int i = 0; i <= 2 * k + 1; i++)
      |                                  ^
a.cc:52:45: error: 'j' was not declared in this scope
   52 |                                         if (j == n && k == m) dp[i][j][k] = 1;
      |                                             ^
a.cc:77:62: error: expected primary-expression before ')' token
   77 |                                         for (int x = j; x <= )
      |                                                              ^
a.cc:77:61: error: expected ';' before ')' token
   77 |                                         for (int x = j; x <= )
      |                                                             ^~
      |                                                             ;
a.cc:79:17: error: expected primary-expression before '}' token
   79 |                 }
      |                 ^
a.cc:86:2: error: expected '}' at end of input
   86 | }
      |  ^
a.cc:34:1: note: to match this '{'
   34 | {
      | ^