Language: C++

//R<3S
#include <bits/stdc++.h>
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define initarr(a,n,x) for (int i=0;i<n;++i) a[i]=x
#define int long long
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define invect(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);}
#define inset(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.insert(tmp);}
#define ll long long
 
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
 
using namespace std;
int flag=0;
void find(int i,vector<string>& v,int a,int b,int c,string& ans)
{
  	if(flag)return;
	if(a<0||b<0||c<0)return;
	if(i==sz(v)&&a>=0&&b>=0&&c>=0){if(flag==0){cout<<"Yes\n";rep(j,sz(ans))cout<<ans[j]<<endl;flag++;}return;}
	if(v[i]=="AB"){find(i+1,v,a-1,b+1,c,ans+'B');find(i+1,v,a+1,b-1,c,ans+'A');}
	else if(v[i]=="BC"){find(i+1,v,a,b+1,c-1,ans+'B');find(i+1,v,a,b-1,c+1,ans+'C');}
	else if(v[i]=="AC"){find(i+1,v,a-1,b,c+1,ans+'C');find(i+1,v,a+1,b,c-1,ans+'A');}
	
}
void solve()
  {
	vector<string>v;
	int n,a,b,c;
	cin>>n>>a>>b>>c;
	rep(i,n)
	{
		string s;cin>>s;
		v.pb(s);
	}
	string ans="";
	find(0,v,a,b,c,ans);
	if(flag==0)cout<<"No";
 
 
  }
 
 
 
signed main()
{
   FAST
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }
 
 
   return 0;
}

Compiler output:
a.cc: In function 'void find(long long int, std::vector<std::__cxx11::basic_string<char> >&, long long int, long long int, long long int, std::string&)':
a.cc:56:28: error: no matching function for call to 'find(long long int, std::vector<std::__cxx11::basic_string<char> >&, long long int, long long int, long long int&, std::__cxx11::basic_string<char>)'
   56 |         if(v[i]=="AB"){find(i+1,v,a-1,b+1,c,ans+'B');find(i+1,v,a+1,b-1,c,ans+'A');}
      |                        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:51:6: note: candidate: 'void find(long long int, std::vector<std::__cxx11::basic_string<char> >&, long long int, long long int, long long int, std::string&)' (near match)
   51 | void find(int i,vector<string>& v,int a,int b,int c,string& ans)
      |      ^~~~
a.cc:51:6: note:   conversion of argument 6 would be ill-formed:
a.cc:56:48: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>'
   56 |         if(v[i]=="AB"){find(i+1,v,a-1,b+1,c,ans+'B');find(i+1,v,a+1,b-1,c,ans+'A');}
      |                                             ~~~^~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   candidate expects 3 arguments, 6 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 6 provided
In file included from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candidate expects 3 arguments, 6 provided
a.cc:56:58: error: no matching function for call to 'find(long long int, std::vector<std::__cxx11::basic_string<char> >&, long long int, long long int, long long int&, std::__cxx11::basic_string<char>)'
   56 |         if(v[i]=="AB"){find(i+1,v,a-1,b+1,c,ans+'B');find(i+1,v,a+1,b-1,c,ans+'A');}
      |                                                      ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:51:6: note: candidate: 'void find(long long int, std::vector<std::__cxx11::basic_string<char> >&, long long int, long long int, long long int, std::string&)' (near match)
   51 | void find(int i,vector<string>& v,int a,int b,int c,string& ans)
      |      ^~~~
a.cc:51:6: note:   conversion of argument 6 would be ill-formed:
a.cc:56:78: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>'
   56 |         if(v[i]=="AB"){find(i+1,v,a-1,b+1,c,ans+'B');find(i+1,v,a+1,b-1,c,ans+'A');}
      |                                                                           ~~~^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   candidate expects 3 arguments, 6 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 6 provided
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candidate expects 3 arguments, 6 provided
a.cc:57:33: error: no matching function for call to 'find(long long int, std::vector<std::__cxx11::basic_string<char> >&, long long int&, long long int, long long int, std::__cxx11::basic_string<char>)'
   57 |         else if(v[i]=="BC"){find(i+1,v,a,b+1,c-1,ans+'B');find(i+1,v,a,b-1,c+1,ans+'C');}
      |                             ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:51:6: note: candidate: 'void find(long long int, std::vector<std::__cxx11::basic_string<char> >&, long long int, long long int, long long int, std::string&)' (near match)
   51 | void find(int i,vector<string>& v,int a,int b,int c,string& ans)
      |      ^~~~
a.cc:51:6: note:   conversion of argument 6 would be ill-formed:
a.cc:57:53: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>'
   57 |         else if(v[i]=="BC"){find(i+1,v,a,b+1,c-1,ans+'B');find(i+1,v,a,b-1,c+1,ans+'C');}
      |                                                  ~~~^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   candidate expects 3 arguments, 6 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 6 provided
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candidate expects 3 arguments, 6 provided
a.cc:57:63: error: no matching function for call to 'find(long long int, std::vector<std::__cxx11::basic_string<char> >&, long long int&, long long int, long long int, std::__cxx11::basic_string<char>)'
   57 |         else if(v[i]=="BC"){find(i+1,v,a,b+1,c-1,ans+'B');find(i+1,v,a,b-1,c+1,ans+'C');}
      |                                                           ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:51:6: note: candidate: 'void find(long long int, std::vector<std::__cxx11::basic_string<char> >&, long long int, long long int, long long int, std::string&)' (near match)
   51 | void find(int i,vector<string>& v,int a,int b,int c,string& ans)
      |      ^~~~
a.cc:51:6: note:   conversion of argument 6 would be ill-formed:
a.cc:57:83: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>'
   57 |         else if(v[i]=="BC"){find(i+1,v,a,b+1,c-1,ans+'B');find(i+1,v,a,b-1,c+1,ans+'C');}
      |                                                                                ~~~^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
 3842 |     find(_InputIterator __first, _InputIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note:   candidate expects 3 arguments, 6 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
   60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note:   candidate expects 4 arguments, 6 provided
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
  435 |     find(istreambuf_iterator<_CharT> __first,
      |     ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note:   candid