Submission
Status:
(PPPPPPPPPP)(PPPPP)(PPPPP)(PPPPPPPPPP)
Subtask/Task Score:
{20/20}{30/30}{30/30}{20/20}
Score: 100
User: C12
Problemset: กองไฟ
Language: cpp
Time: 0.004 second
Submitted On: 2026-03-09 23:10:01
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
long dp[51][51][51][3][3] = {0};
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n,a,b,c;
cin >> n >> a >> b >> c;
dp[0][0][1][2][2] = 1;
dp[0][1][0][1][1] = 1;
dp[1][0][0][0][0] = 1;
for(int i = 0;i <= a;i++){
for(int j = 0;j <= b;j++){
for(int k = 0;k <= c;k++){
for(int f = 0;f < 3;f++){
if(i > 0){
dp[i][j][k][0][f] += (dp[i-1][j][k][1][f] + dp[i-1][j][k][2][f]) % mod;
}
if(j > 0){
dp[i][j][k][1][f] += (dp[i][j-1][k][0][f] + dp[i][j-1][k][2][f]) % mod;
}
if(k > 0){
dp[i][j][k][2][f] += (dp[i][j][k-1][0][f] + dp[i][j][k-1][1][f]) % mod;
}
}
}
}
}
long out =
(dp[a][b][c][0][1] + dp[a][b][c][0][2]) +
(dp[a][b][c][1][0] + dp[a][b][c][1][2]) +
(dp[a][b][c][2][0] + dp[a][b][c][2][1]);
out %= mod;
cout << out;
return 0;
}
/*
7 16
This is an example of text justification.
6 16
What must be acknowledgement shall be
*/