Submission
Status:
(xSSSSSSSSS)(PPxSS)(xSSSS)(SSSSSSSSSS)
Subtask/Task Score:
{0/20}{0/30}{0/30}{0/20}
Score: 0
User: sorrkub
Problemset: กองไฟ
Language: cpp
Time: 0.002 second
Submitted On: 2026-02-11 20:08:43
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; typedef pair<long long ,long long> pll; typedef pair<long long, pair<long long , long long >> plpll;
const int inf = 1e9+7;
int dx[8] = {0,0,-1,1,-1,1,-1,1} , dy[8] = {1,-1,0,0,1,-1,1,-1};
#define F first
#define S second
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
int mem[50][50][50][4][3];
int n;
int fun(int a,int b, int c , int last,int first){
if(a+b+c == 0){
return 1;
}
if(first == -1){
return fun(a-1,b,c,1,1) + fun(a,b-1,c,2,2) + fun(a,b,c-1,3,3);
}
if(last == 1){
int i=0,j=0;
if(b>0){
i = fun(a,b-1,c,2,first);
}
if(c>0){
j = fun(a,b,c-1,3,first);
}
return mem[a][b][c][last][first] = i+j;
}
if(last == 2){
int i=0,j=0;
if(b>0){
i = fun(a-1,b,c,1,first);
}
if(c>0){
j = fun(a,b,c-1,3,first);
}
return mem[a][b][c][last][first] = i+j;
}
if(last == 3){
int i=0,j=0;
if(b>0){
i = fun(a,b-1,c,2,first);
}
if(c>0){
j = fun(a-1,b,c,3,first);
}
return mem[a][b][c][last][first] = i+j;
}
}
void solve(){
int a,b,c;cin>>n>>a>>b>>c;
cout<<fun(a,b,c,0,-1);
}
signed main(){
FAST_IO
int q=1;
//cin>>q;
while(q--){
solve();
}
return 0;
}
/*
_ooOoo_
o8888888o
88" . "88
(| -_- |)
O\ = /O
____/`---'\____
.' \| |// `.
/ \||| : |||// \
/ _||||| -:- |||||- \
| | \ - /// | |
| \_| ''\---/'' | |
\ .-\__ `-` ___/-. /
___`. .' /--.--\ `. . __
."" '< `.___\_<|>_/___.' >'"".
| | : `- \`.;`\ _ /`;.`/ - ` : | |
\ \ `-. \_ __\ /__ _/ .-` / /
======`-.____`-.___\_____/___.-`____.-'======
`=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pass System Test!
*/