1051C.md (1598B)
1 Source: https://codeforces.com/problemset/problem/1051/C 2 3 C. Vasya and Multisets 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Vasya has a multiset $s$ consisting of $n$ integer numbers. Vasya calls some number $x$ nice if it appears in the multiset exactly once. For example, multiset $\{1, 1, 2, 3, 3, 3, 4\}$ contains nice numbers $2$ and $4$. 22 23 Vasya wants to split multiset $s$ into two multisets $a$ and $b$ (one of which may be empty) in such a way that the quantity of nice numbers in multiset $a$ would be the same as the quantity of nice numbers in multiset $b$ (the quantity of numbers to appear exactly once in multiset $a$ and the quantity of numbers to appear exactly once in multiset $b$). 24 25 Input 26 27 The first line contains a single integer $n~(2 \le n \le 100)$. 28 29 The second line contains $n$ integers $s_1, s_2, \dots s_n~(1 \le s_i \le 100)$ — the multiset $s$. 30 31 Output 32 33 If there exists no split of $s$ to satisfy the given requirements, then print "NO" in the first line. 34 35 Otherwise print "YES" in the first line. 36 37 The second line should contain a string, consisting of $n$ characters. $i$-th character should be equal to 'A' if the $i$-th element of multiset $s$ goes to multiset $a$ and 'B' if if the $i$-th element of multiset $s$ goes to multiset $b$. Elements are numbered from $1$ to $n$ in the order they are given in the input. 38 39 If there exist multiple solutions, then print any of them. 40 41 Examples 42 43 Input 44 45 ``` 46 4 47 3 5 7 1 48 ``` 49 50 Output 51 52 ``` 53 YES 54 BABA 55 ``` 56 57 Input 58 59 ``` 60 3 61 3 5 1 62 ``` 63 64 Output 65 66 ``` 67 NO 68 ```