题目链接:https://codeforces.com/problemset/problem/1051/C
统计出现一次的数的奇偶性
再统计出现三次以上的数是否出现过,补齐即可
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;
const int maxn = 110;
int n;
int a[maxn],bas[maxn];
ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }
int main(){
n = read();
int ma = 0;
for(int i=1;i<=n;++i) a[i] = read(), ++bas[a[i]], ma = max(ma,a[i]);
int cnt1 = 0, cnt2 = 0;
for(int i=1;i<=ma;++i){
if(bas[i]==1) ++cnt1;
if(bas[i]>=3) ++cnt2;
//if(bas[i]>3) ++cnt3;
}
if(cnt1%2 == 0){
printf("YES
");
int rec = 0;
for(int i=1;i<=n;++i){
if(bas[a[i]] == 1){
if(rec<cnt1/2) printf("A");
else printf("B");
++rec;
}else {
printf("B");
}
}
}else{
if(cnt2>=1){
printf("YES
");
int rec = 0, f = 0;
for(int i=1;i<=n;++i){
if(bas[a[i]] == 1){
if(rec<cnt1/2) printf("A");
else printf("B");
++rec;
}
else if(bas[a[i]] >=3 ){
if(!f){
printf("A");
f=1;
}else printf("B");
}else{
printf("B");
}
}
}else{
printf("NO
");
}
}
return 0;
}