Problem p02692 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl /*, greater<ll>*/> pql; // 降順(/*昇順*/)
typedef set<ll> sl;
#define rep(i, n) for (ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for (ll i = 1; i <= ll(n); ++i)
// #define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
// #define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
bool chmax(ll &a, ll b) {
  if (b > a) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\\n';

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll n;
  cin >> n;
  vl a(3);
  rep(i, 3) cin >> a[i];
  vs s(n);
  rep(i, n) cin >> s[i];

  bool able = 1;
  string ans;
  rep(i, n) {
    ll &ch1 = a[s[i][0] - 'A'], &ch2 = a[s[i][1] - 'A'];
    if (ch1 == 0 && ch2 == 0) {
      able = 0;
      break;
    } else if (i < n - 1 && a[s[i][0] - 'A'] == 1 && a[s[i][1] - 'A'] == 1) {
      if (s[i][0] == s[i + 1][0] || s[i][0] == s[i + 1][1]) {
        ch1++;
        ch2--;
        ans += s[i][0];
      } else {
        ch2++;
        ch1--;
        ans += s[i][1];
      }
    } else {
      if (ch1 < ch2) {
        ch1++;
        ch2--;
        ans += s[i][0];
      } else {
        ch2++;
        ch1--;
        ans += s[i][1];
      }
    }
  }

  if (able) {
    cout << "Yes" << newl;
    rep(i, n) cout << ans[i] << newl;
  } else
    cout << "No" << newl;
  return 0;
}

Error: 255

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl /*, greater<ll>*/> pql; // 降順(/*昇順*/)
typedef set<ll> sl;
#define rep(i, n) for (ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for (ll i = 1; i <= ll(n); ++i)
// #define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
// #define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
bool chmax(ll &a, ll b) {
  if (b > a) {
    a = b;
    return 1;
  }
  return 0;
}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\\n';

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll n, a, b, c, sum;
  cin >> n >> a >> b >> c;
  sum = a + b + c;

  if (sum <= 9)
    return -1;

  bool able = 1;
  vc ans;
  string s;
  rep(_, n) {
    cin >> s;
    if (s == "AB") {
      if (a == 0 & b == 0)
        able = 0;
      else if (a < b) {
        a++, b--;
        ans.push_back('A');
      } else {
        b++, a--;
        ans.push_back('B');
      }
    }

    if (s == "AC") {
      if (a == 0 & c == 0)
        able = 0;
      if (a < c) {
        a++, c--;
        ans.push_back('A');
      } else {
        c++, a--;
        ans.push_back('C');
      }
    }

    if (s == "BC") {
      if (b == 0 & c == 0)
        able = 0;
      if (b < c) {
        b++, c--;
        ans.push_back('B');
      } else {
        c++, b--;
        ans.push_back('C');
      }
    }
  }
  if (able) {
    cout << "Yes" << newl;
    for (char i : ans)
      cout << i << newl;
  } else {
    cout << "No" << newl;
  }
  return 0;
}