Educational Codeforces Round 51 (Rated for Div. 2) C Vasya and Multisets 【水题】

C. Vasya and Multisets

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Vasya has a multiset ss consisting of nn integer numbers. Vasya calls some number xx nice if it appears in the multiset exactly once. For example, multiset {1,1,2,3,3,3,4}{1,1,2,3,3,3,4} contains nice numbers 22 and 44.

Vasya wants to split multiset ss into two multisets aa and bb (one of which may be empty) in such a way that the quantity of nice numbers in multiset aa would be the same as the quantity of nice numbers in multiset bb (the quantity of numbers to appear exactly once in multiset aaand the quantity of numbers to appear exactly once in multiset bb).

Input

The first line contains a single integer n (2≤n≤100)n (2≤n≤100).

The second line contains nn integers s1,s2,…sn (1≤si≤100)s1,s2,…sn (1≤si≤100) — the multiset ss.

Output

If there exists no split of ss to satisfy the given requirements, then print "NO" in the first line.

Otherwise print "YES" in the first line.

The second line should contain a string, consisting of nn characters. ii-th character should be equal to 'A' if the ii-th element of multiset ssgoes to multiset aa and 'B' if if the ii-th element of multiset ss goes to multiset bb. Elements are numbered from 11 to nn in the order they are given in the input.

If there exist multiple solutions, then print any of them.

Examples

input

Copy

4
3 5 7 1

output

Copy

YES
BABA

input

Copy

3
3 5 1

output

Copy

NO
#include<bits/stdc++.h>
using namespace std;
const int MAX = 105;
int vis[MAX], a[MAX];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        vis[a[i]]++;
    }
    int j = 0, o = 0, d = 0;
    for(int i = 1; i <= 100; i++){
        if(vis[i] == 1) j++;
        if(vis[i] == 2) o++;
        if(vis[i] > 2) d++;
    }
    if((j & 1) == 0 || ((j & 1) && d)){
        cout << "YES" << endl;
        if((j & 1) == 0){
            int num = j / 2;
            for(int i = 0; i < n; i++){
                if(vis[a[i]] == 1 && num > 0){
                    cout << "A";
                    num--;
                }
                else cout << "B";
            }
        }
        else{
            int num = j / 2, cnt = 1;
            for(int i = 0; i < n; i++){
                if(vis[a[i]] == 1 && num > 0 || (vis[a[i]] > 2 && cnt > 0)){
                    cout << "A";
                    if(vis[a[i]] > 2) cnt--;
                    else num--;
                }
                else cout << "B";
            }
        }
    }
    else return cout << "NO" << endl, 0;
    return 0;
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值