Language: C++

#include<bits/stdc++.h>
#define mz 998244353
#define pq priority_queue
using namespace std;

char s[6];
char ans[100005];
int n,x[100005],y[100005];
int dp[100005][6][6][6];

int dfs(int i,int a[3])
{
    if(i>n)
        return 1;
    if(dp[i][a[0]][a[1]][a[2]])
        return dp[i][a[0]][a[1]][a[2]];
    if(a[x[i]]==0 && a[y[i]]==0)
        return dp[i][a[0]][a[1]][a[2]]-1;
    if(a[y[i]]!=0)
    {
        a[y[i]]--;
        a[x[i]]++;
        ans[i]=x[i]+'A';
        if(dfs(i+1,a[0],a[1],a[2])==1)
            return return dp[i][a[0]][a[1]][a[2]]=1;
    }
    if(a[x[i]]!=0)
    {
        a[x[i]]--;
        a[y[i]]++;
        ans[i]=y[i]+'A';
        if(dfs(i+1,a[0],a[1],a[2])==1)
            return return dp[i][a[0]][a[1]][a[2]]=1;
    }
    return dp[i][a[0]][a[1]][a[2]]=-1;
}

int main()
{
    int a,b,c;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    a=min(1,a);
    b=min(1,b);
    c=min(1,c);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s);
        x[i]=s[0]-'A';
        y[i]=s[1]-'A';
    }
    if(dfs(1,a,b,c)==-1)
        printf("No\n");
    else
    {
        printf("Yes\n");
        for(int i=1;i<=n;i++)
            printf("%c\n",ans[i]);
    }
    return 0;
}
/*
5 6 9 1
BC
AC
BC
AB
AB
*/


Compiler output:
a.cc: In function 'int dfs(int, int*)':
a.cc:24:23: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   24 |         if(dfs(i+1,a[0],a[1],a[2])==1)
      |                    ~~~^
      |                       |
      |                       int
a.cc:24:15: error: too many arguments to function 'int dfs(int, int*)'
   24 |         if(dfs(i+1,a[0],a[1],a[2])==1)
      |            ~~~^~~~~~~~~~~~~~~~~~~~
a.cc:11:5: note: declared here
   11 | int dfs(int i,int a[3])
      |     ^~~
a.cc:25:20: error: expected primary-expression before 'return'
   25 |             return return dp[i][a[0]][a[1]][a[2]]=1;
      |                    ^~~~~~
a.cc:25:19: error: expected ';' before 'return'
   25 |             return return dp[i][a[0]][a[1]][a[2]]=1;
      |                   ^~~~~~~
      |                   ;
a.cc:32:23: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   32 |         if(dfs(i+1,a[0],a[1],a[2])==1)
      |                    ~~~^
      |                       |
      |                       int
a.cc:32:15: error: too many arguments to function 'int dfs(int, int*)'
   32 |         if(dfs(i+1,a[0],a[1],a[2])==1)
      |            ~~~^~~~~~~~~~~~~~~~~~~~
a.cc:11:5: note: declared here
   11 | int dfs(int i,int a[3])
      |     ^~~
a.cc:33:20: error: expected primary-expression before 'return'
   33 |             return return dp[i][a[0]][a[1]][a[2]]=1;
      |                    ^~~~~~
a.cc:33:19: error: expected ';' before 'return'
   33 |             return return dp[i][a[0]][a[1]][a[2]]=1;
      |                   ^~~~~~~
      |                   ;
a.cc: In function 'int main()':
a.cc:51:14: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   51 |     if(dfs(1,a,b,c)==-1)
      |              ^
      |              |
      |              int
a.cc:51:11: error: too many arguments to function 'int dfs(int, int*)'
   51 |     if(dfs(1,a,b,c)==-1)
      |        ~~~^~~~~~~~~
a.cc:11:5: note: declared here
   11 | int dfs(int i,int a[3])
      |     ^~~