Submission
Status:
(PPPPPPPPPP)(PPPPP)(PPPPP)(PPPPTSSSSS)
Subtask/Task Score:
{20/20}{30/30}{30/30}{0/20}
Score: 80
User: devilpoohs
Problemset: กองไฟ
Language: cpp
Time: 1.095 second
Submitted On: 2026-03-06 16:17:17
#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
*/