Submission

Status:

[-SSSSSSSSSSSS]

Subtask/Task Score:

{0/100}

Score: 0

User: devilpoohs

Problemset: ซื้อขายหุ้นซีเค

Language: cpp

Time: 0.002 second

Submitted On: 2026-03-06 15:59:41

#include<bits/stdc++.h>
using namespace std;
vector<string> v;
int cnt=0;
void think(int i,int a,int b,int c,int tpe){
    if(i==0){
        // for(auto&j:v){
        //     cout<<j;
        // }
        // cout<<'\n';
        cnt++;
        return ;
    }
    if(i==1){
        // cout<<'a';
        if(tpe==0 and a>0){
            if(v[0]!="A"){
                think(i-1,a-1,b,c,0);
            }
        }
        if(tpe==1 and b>0){
            if(v[0]!="B"){
                think(i-1,a,b-1,c,1);
            }
        }
        if(tpe==2 and c>0){
            if(v[0]!="C"){
                think(i-1,a,b,c-1,2);
            }
        }
    }else{
        if(tpe==0 and a>0){
            v.emplace_back("A");
            think(i-1,a-1,b,c,1);
            v.pop_back();
            
            
            v.emplace_back("A");
            think(i-1,a-1,b,c,2);
            v.pop_back();
        }else if(tpe==1 and b>0){
            v.emplace_back("B");
            think(i-1,a,b-1,c,0);
            v.pop_back();
            
            
            v.emplace_back("B");
            think(i-1,a,b-1,c,2);
            v.pop_back();
        }else if(tpe==2 and c>0){
            v.emplace_back("C");
            think(i-1,a,b,c-1,1);
            v.pop_back();
            
            
            v.emplace_back("C");
            think(i-1,a,b,c-1,0);
            v.pop_back();
        }   
    }
    
     
}

int main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    int n,a,b,c;
    cin>>n>>a>>b>>c;
    for(int i=0;i<3;i++)
        think(n,a,b,c,i);
    cout<<cnt;
    return 0;
}
/*
7
3 3 1
*/