59 lines
1.3 KiB
Java
59 lines
1.3 KiB
Java
package chelper;
|
|
|
|
import io.InputReader;
|
|
import io.OutputWriter;
|
|
import misc.SimpleSavingChelperSolution;
|
|
|
|
|
|
public class TaskD extends SimpleSavingChelperSolution {
|
|
|
|
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
|
wrapSolve(testNumber, in, out);
|
|
}
|
|
|
|
int MOD = 998244353;
|
|
|
|
int[][] componentChanges = {
|
|
{0, 1, 1, 1}, //00
|
|
{0, 0, 2, 0}, //01
|
|
{0, 2, 0, 0}, //10
|
|
{1, 1, 1, 0}, //11
|
|
};
|
|
|
|
@Override
|
|
public void solve(int testNumber) {
|
|
int n = in.nextInt();
|
|
int colors = in.nextInt();
|
|
|
|
int[][][] dp = new int[n][colors + 10][4];
|
|
|
|
dp[0][1][0]++;
|
|
dp[0][2][1]++;
|
|
dp[0][2][2]++;
|
|
dp[0][1][3]++;
|
|
|
|
for (int i = 0; i < n - 1; i++) {
|
|
for (int k = 0; k <= colors; k++) {
|
|
for (int curMask = 0; curMask < 4; curMask++) {
|
|
for (int nextMask = 0; nextMask < 4; nextMask++) {
|
|
int newK = k + componentChanges[curMask][nextMask];
|
|
if (newK > colors) {
|
|
continue;
|
|
}
|
|
|
|
dp[i + 1][newK][nextMask] += dp[i][k][curMask];
|
|
dp[i + 1][newK][nextMask] %= MOD;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
int result = 0;
|
|
for (int i = 0; i < 4; i++) {
|
|
result += dp[n - 1][colors][i];
|
|
result %= MOD;
|
|
}
|
|
out.println(result);
|
|
}
|
|
}
|