Language: C++

#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i <= n; i++)
#define repl(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
#define STR(var) #var
typedef long long ll;

using namespace std;

vector<int> select;
int N, A, B, C;

int main(){
  int A[3]; 
  cin >> N >> A[0] >> A[1] >> A[2];
  vector<pair<int,int>> operate_turn;
  vector<string> operate;
  repl(i,0,N){

    string s;
    cin >> s;
    operate.push_back(s);
    if(s=="AB") operate_turn.push_back(make_pair(0,1));
    if(s=="BC") operate_turn.push_back(make_pair(1,2));
    if(s=="AC") operate_turn.push_back(make_pair(0,2));
  }
  if(A[0]+A[1]+A[2]==0){
    cout << "No" << endl;
  }else if(A[0]+A[1]+A[2]==1){
    repl(i,0,N){
      int first=operate_turn[i].first;
      int second=operate_turn[i].second;
      
      if(A[first]==0 && A[second]>0){
        A[first]++;
        A[second]--;
        select.push_back(first);
      }else if(A[first]>0 && A[second]==0){
        A[second]++;
        A[first]--;
        select.push_back(second);
      }else{
        cout << "No" << endl;
        return 0;
      }
    }
  }else{
    int first=operate_turn[0].first;
    int second=operate_turn[0].second;
    if(A[first]==0 && A[second]==0){
      cout << "No" << endl;
      return 0;
    }
    cout << "Yes" << endl;
    repl(i,0,N){
        //cout << first << " " << second << endl;
        //cout << i << " "<< A[0] <<" " << A[1] <<" " <<A[2] << endl;
      int first=operate_turn[i].first;
      int second=operate_turn[i].second;
      int first_next, second_next;
      if(i<N){
        first_next=operate_turn[0].first;
        second_next=operate_turn[0].second;
      }
      if(A[first]==0 && A[second]>0){
        A[first]++;
        A[second]--;
        select.push_back(first);
        continue;
      }else if(A[first]>0 && A[second]==0){
        A[second]++;
        A[first]--;
        select.push_back(second);
        continue;
      }
      if(A[0]+A[1]+A[2]>=2 && i<N && (first != first_next || second != second_next)){
        if(first==first_next){
          A[first]++;
          A[second]--;
          select.push_back(first);
          continue;
        }else if(second==second_next){
          A[second]++;
          A[first]--;
        select.push_back(second);
          continue;
        }else{
          A[1]++;
          select.push_back(1);
          if(first==1){
            A[second]--;
          }else{
            A[first]--;
          }
          continue;
        }
      }
      A[first]++;
      A[second]--;
      select.push_back(first);
    }
  }

  for(int i:select){
    char str[] = {'A', 'B', 'C'};
    cout << str[i] << endl;
  }
  
  return 0;
}



Compiler output:
a.cc:10:13: error: 'std::vector<int> select' redeclared as different kind of entity
   10 | vector<int> select;
      |             ^~~~~~
In file included from /usr/include/x86_64-linux-gnu/sys/types.h:179,
                 from /usr/include/stdlib.h:514,
                 from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/sys/select.h:102:12: note: previous declaration 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)'
  102 | extern int select (int __nfds, fd_set *__restrict __readfds,
      |            ^~~~~~
a.cc: In function 'int main()':
a.cc:37:16: error: request for member 'push_back' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
   37 |         select.push_back(first);
      |                ^~~~~~~~~
a.cc:41:16: error: request for member 'push_back' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
   41 |         select.push_back(second);
      |                ^~~~~~~~~
a.cc:68:16: error: request for member 'push_back' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
   68 |         select.push_back(first);
      |                ^~~~~~~~~
a.cc:73:16: error: request for member 'push_back' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
   73 |         select.push_back(second);
      |                ^~~~~~~~~
a.cc:80:18: error: request for member 'push_back' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
   80 |           select.push_back(first);
      |                  ^~~~~~~~~
a.cc:85:16: error: request for member 'push_back' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
   85 |         select.push_back(second);
      |                ^~~~~~~~~
a.cc:89:18: error: request for member 'push_back' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
   89 |           select.push_back(1);
      |                  ^~~~~~~~~
a.cc:100:14: error: request for member 'push_back' in 'select', which is of non-class type 'int(int, fd_set*, fd_set*, fd_set*, timeval*)'
  100 |       select.push_back(first);
      |              ^~~~~~~~~
a.cc:104:13: error: 'begin' was not declared in this scope
  104 |   for(int i:select){
      |             ^~~~~~
a.cc:104:13: note: suggested alternatives:
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/valarray:1238:5: note:   'std::begin'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
In file included from /usr/include/c++/14/filesystem:53,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200:
/usr/include/c++/14/bits/fs_dir.h:608:3: note:   'std::filesystem::__cxx11::begin'
  608 |   begin(recursive_directory_iterator __iter) noexcept
      |   ^~~~~
a.cc:104:13: error: 'end' was not declared in this scope
  104 |   for(int i:select){
      |             ^~~~~~
a.cc:104:13: note: suggested alternatives:
/usr/include/c++/14/valarray:1265:5: note:   'std::end'
 1265 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/14/bits/fs_dir.h:613:3: note:   'std::filesystem::__cxx11::end'
  613 |   end(recursive_directory_iterator) noexcept
      |   ^~~