Language: C++

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define debug(x) cout<<x<<'\n'
#define pii pair<ll,pair<ll,ll> >
using namespace std;
const int inf = 0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9+7;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll powmod(ll a,ll b){
    ll ans = 1, pow = a;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans;
}
ll mul(ll a,ll b){//大数取模乘法防止溢出
    ll ans=0;
    a%=mod,b%=mod;
    while(b) { if(b&1) ans = (ans+a)%mod; a = (a*2)%mod; b >>= 1; }
    return ans;
}
//(b/a)%p=b*a^(p-2)%p
int pr(ll num){//判断素数
     if(num == 1) return 0;
     if(num ==2|| num==3 ) return 1 ;
     if(num %6!= 1&&num %6!= 5) return 0 ;
     int tmp =sqrt( num);
     for(int i= 5;i <=tmp; i+=6 )
          if(num %i== 0||num %(i+ 2)==0 )return 0 ;
     return 1 ;
}
int Day(int y,int m, int d){
    if(m==1||m==2) { m+=12; y--; }
    int w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;
    return w+1;
}
inline int read() {
    int c = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        c = c * 10 + ch - '0';
        ch = getchar();
    }
    return c * f;
}

//#pragma comment(linker, "/STACK:1024000000,1024000000")//外挂开栈
//stable_sort 排序不处理相同元素
//map<int,int>::reverse_iterator rit;
//for(rit=mp.rbegin();rit!=mp.rend();rit++)
//vec动态二维数组
//vector<vector<int>> g(26,vector<int>(100005));
//初始化vec里面套了n个vec

//lower_bound(begin,end,num) 有序数列中返回第一个>=num的数字的地址
//upper_bound( begin,end,num) 返回第一个>num的数字的地址

const int maxn=1e5+5;
string s[maxn];
ll n,A,B,C;
string ans="";
void Do(ll &aa,ll &bb,char x,char y,int i){
    if(aa<bb){
        ans+=x;
        aa++,bb--;
    }
    else if(aa>bb){
        ans+=y;
        aa--,bb++;
    }
    else{
        if(i==n-1){
            ans+=x;
            aa++,bb--;
        }
        else{
            if(s[i+1][0]==x){
                a++;b--;
                ans+=x;
            }
            else{
                a--;b++;
                ans+=y;
            }
        }
    }
}
int main(){
    cin>>n>>A>>B>>C;
    for(int i=0;i<n;++i){
        cin>>s[i];
    }
    for(int i=0;i<n;++i){
        if(s[i]=="AB"){
            Do(A,B,'A','B',i);
        }
        else if(s[i]=="AC"){
            Do(A,C,'A','C',i);
        }
        else{
            Do(B,C,'B','C',i);
        }
    }
    if(A>=0&&B>=0&&C>=0){
        cout<<"Yes"<<endl;
        for(int i=0;i<ans.size();++i){
            cout<<ans[i]<<endl;
        }
    }
    else cout<<"No"<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'void Do(long long int&, long long int&, char, char, int)':
a.cc:94:17: error: 'a' was not declared in this scope
   94 |                 a++;b--;
      |                 ^
a.cc:94:21: error: 'b' was not declared in this scope
   94 |                 a++;b--;
      |                     ^
a.cc:98:17: error: 'a' was not declared in this scope
   98 |                 a--;b++;
      |                 ^
a.cc:98:21: error: 'b' was not declared in this scope
   98 |                 a--;b++;
      |                     ^