Language: C++

#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;	
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

#include <bits/stdc++.h>
using namespace std;

const ll INF = 1e15;
vector<ll> scores[3];
ll n;
vector<int> arg;
ll th[3];

int process(int i, int id1, int id2) {
	ll dist1 = std::lower_bound(scores[id1].begin() + i, scores[id1].end(), th[id1]) - (scores[id1].begin() + i);
	ll dist2 = std::lower_bound(scores[id2].begin() + i, scores[id2].end(), th[id2]) - (scores[id2].begin() + i);
	if (dist1 <= 0 && dist2 <= 0) {
		return -1;
	}
	if (dist1 < dist2) {
		th[id1] += 2;
		return id1;
	}
	else {
		th[id2] += 2;
		return id2;
	}
}

int main() {
	ll init[3];
	cin >> n >> init[0] >> init[1] >> init[2];
	arg.resize(n);
	rep(i, 3) {
		scores[i].resize(n + 1);
		scores[i][0] = -init[i];
	}
	rep(i, n) {
		string s;
		cin >> s;
		if (s == "AB") {
			scores[0][i + 1] = scores[0][i] + 1;
			scores[1][i + 1] = scores[1][i] + 1;
			scores[2][i + 1] = scores[2][i];
			arg[i] = 0;
		}
		if (s == "BC") {
			scores[0][i + 1] = scores[0][i];
			scores[1][i + 1] = scores[1][i] + 1;
			scores[2][i + 1] = scores[2][i] + 1;
			arg[i] = 1;
		}
		if (s == "AC") {
			scores[0][i + 1] = scores[0][i] + 1;
			scores[1][i + 1] = scores[1][i];
			scores[2][i + 1] = scores[2][i] + 1;
			arg[i] = 2;
		}
	}
	vector<string> ans;
	th[0] = th[1] = th[2] = 1;
	for (int i = 0; i < n;i++) {
		if (arg[i] == 0) {
			auto p = process(i+1, 0, 1);
			if(p < 0){
				cout << "No" << endl;
				return 0;
			}
			if (p == 0) {
				ans.push_back("A");
			}
			else {
				ans.push_back("B");
			}
		}
		else if (arg[i] == 1){
			auto p = process(i + 1, 1, 2);
			if (p < 0) {
				cout << "No" << endl;
				return 0;
			}
			if (p == 1) {
				ans.push_back("B");
			}
			else {
				ans.push_back("C");
			}
		}
		else {
			auto p = process(i + 1, 0, 2);
			if (p < 0) {
				cout << "No" << endl;
				return 0;
			}
			if (p == 0) {
				ans.push_back("A");
			}
			else {
				ans.push_back("C");
			}

		}
	}
	cout << "Yes" << endl;
	for (string c : ans) {
		cout << c << endl;
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:9: error: reference to 'arg' is ambiguous
   44 |         arg.resize(n);
      |         ^~~
In file included from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
                 from a.cc:1:
/usr/include/c++/14/complex:2435:5: note: candidates are: 'template<class _Tp> typename __gnu_cxx::__promote<_Tp, std::__is_integer<_Tp>::__value>::__type std::arg(_Tp)'
 2435 |     arg(_Tp __x)
      |     ^~~
/usr/include/c++/14/complex:919:5: note:                 'template<class _Tp> _Tp std::arg(const complex<_Tp>&)'
  919 |     arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
      |     ^~~
a.cc:22:13: note:                 'std::vector<int> arg'
   22 | vector<int> arg;
      |             ^~~
a.cc:56:25: error: reference to 'arg' is ambiguous
   56 |                         arg[i] = 0;
      |                         ^~~
/usr/include/c++/14/complex:2435:5: note: candidates are: 'template<class _Tp> typename __gnu_cxx::__promote<_Tp, std::__is_integer<_Tp>::__value>::__type std::arg(_Tp)'
 2435 |     arg(_Tp __x)
      |     ^~~
/usr/include/c++/14/complex:919:5: note:                 'template<class _Tp> _Tp std::arg(const complex<_Tp>&)'
  919 |     arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
      |     ^~~
a.cc:22:13: note:                 'std::vector<int> arg'
   22 | vector<int> arg;
      |             ^~~
a.cc:62:25: error: reference to 'arg' is ambiguous
   62 |                         arg[i] = 1;
      |                         ^~~
/usr/include/c++/14/complex:2435:5: note: candidates are: 'template<class _Tp> typename __gnu_cxx::__promote<_Tp, std::__is_integer<_Tp>::__value>::__type std::arg(_Tp)'
 2435 |     arg(_Tp __x)
      |     ^~~
/usr/include/c++/14/complex:919:5: note:                 'template<class _Tp> _Tp std::arg(const complex<_Tp>&)'
  919 |     arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
      |     ^~~
a.cc:22:13: note:                 'std::vector<int> arg'
   22 | vector<int> arg;
      |             ^~~
a.cc:68:25: error: reference to 'arg' is ambiguous
   68 |                         arg[i] = 2;
      |                         ^~~
/usr/include/c++/14/complex:2435:5: note: candidates are: 'template<class _Tp> typename __gnu_cxx::__promote<_Tp, std::__is_integer<_Tp>::__value>::__type std::arg(_Tp)'
 2435 |     arg(_Tp __x)
      |     ^~~
/usr/include/c++/14/complex:919:5: note:                 'template<class _Tp> _Tp std::arg(const complex<_Tp>&)'
  919 |     arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
      |     ^~~
a.cc:22:13: note:                 'std::vector<int> arg'
   22 | vector<int> arg;
      |             ^~~
a.cc:74:21: error: reference to 'arg' is ambiguous
   74 |                 if (arg[i] == 0) {
      |                     ^~~
/usr/include/c++/14/complex:2435:5: note: candidates are: 'template<class _Tp> typename __gnu_cxx::__promote<_Tp, std::__is_integer<_Tp>::__value>::__type std::arg(_Tp)'
 2435 |     arg(_Tp __x)
      |     ^~~
/usr/include/c++/14/complex:919:5: note:                 'template<class _Tp> _Tp std::arg(const complex<_Tp>&)'
  919 |     arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
      |     ^~~
a.cc:22:13: note:                 'std::vector<int> arg'
   22 | vector<int> arg;
      |             ^~~
a.cc:87:26: error: reference to 'arg' is ambiguous
   87 |                 else if (arg[i] == 1){
      |                          ^~~
/usr/include/c++/14/complex:2435:5: note: candidates are: 'template<class _Tp> typename __gnu_cxx::__promote<_Tp, std::__is_integer<_Tp>::__value>::__type std::arg(_Tp)'
 2435 |     arg(_Tp __x)
      |     ^~~
/usr/include/c++/14/complex:919:5: note:                 'template<class _Tp> _Tp std::arg(const complex<_Tp>&)'
  919 |     arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
      |     ^~~
a.cc:22:13: note:                 'std::vector<int> arg'
   22 | vector<int> arg;
      |             ^~~