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
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;
}

 

你可能感兴趣的:(基础水题)