You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB
C++

#include <bits/stdc++.h>
using namespace std;
int a[110];
int main() {
int n;
cin >> n;
map<int, int> M;
for (int i = 0; i < n; i++) scanf("%d", a + i);
for (int i = 0; i < n; i++) M[a[i]]++;
int cur = 1;
set<int> s[2];
for (auto const &x:M)
if (x.second == 1)
s[cur ^= 1].insert(x.first);
string ans(n, 'A');
if (s[0].size() == s[1].size()) {
for (int i = 0; i < n; ++i)
if (s[1].count(a[i]))
ans[i] = 'B';
cout << "YES" << endl << ans;
} else {
for (int i = 0; i < n; ++i)
if (s[1].count(a[i]))
ans[i] = 'B';
if (auto idx = find_if(M.begin(), M.end(), [](const auto &x) { return x.second >= 3; });idx == M.end())
cout << "NO";
else {
for (int i = 0; i < n; i++)
if (a[i] == idx->first) {
ans[i] = 'B';
break;
}
cout << "YES" << endl << ans;
}
}
return 0;
}