CF BUDDY
← Problems·

1051C · Vasya and Multisets

1500 · brute force, dp, greedy

Problem: 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 aa and the quantity of numbers to appear exactly once in multiset bb).

Input Format: The first line contains a single integer n (2n100)n~(2 \le n \le 100).

The second line contains nn integers s1,s2,sn (1si100)s_1, s_2, \dots s_n~(1 \le s_i \le 100) — the multiset ss.

Output Format: 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 ss goes 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.

Sample Cases

Case 1

Input

4
3 5 7 1

Output

YES
BABA

Case 2

Input

3
3 5 1

Output

NO

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback