1. 程式人生 > >Educational Codeforces Round 51 (Rated for Div. 2)

Educational Codeforces Round 51 (Rated for Div. 2)

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.

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<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;
#define rep(i,j,k) for(int i=j;i<=k;i++)
#define sca(x) scanf("%d",&x)
#define per(i,j,k) for(int i=j;i>=k;i--)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define N 200005
#define inf 0x3f3f3f3f

int a[105];
int vis[105];
int ans[105];
int main()
{
    int n;
    sca(n);
    rep(i,0,n-1)
    {
        sca(a[i]);
        vis[a[i]]++;
    }
    int num=0;
    string ans;
    for(int i=0;i<n;i++)
    {
        if(vis[a[i]]==1)
        {
            if(num==0)
            {
                ans+='A';
            }
            else if(num==1)
            {
                ans+='B';
            }
            num=!num;
        }
        else ans+='A';
    }
    int flag=0;
    if(num==1)
    {
        rep(i,0,n-1)
        {
            if(vis[a[i]]>2)//如果A>B 則在不增加A集合的前提下,增加B集合符合題意數的個數。
            {
                ans[i]='B';
                flag=1;
                break;
            }
        }
    }
    if(num&&!flag)puts("NO");
    else
    {
        puts("YES");
        cout<<ans<<endl;
    }
}