626B.md (1878B)
1 Source: https://codeforces.com/problemset/problem/626/B 2 3 B. Cards 4 5 time limit per test 6 7 2 seconds 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 Catherine has a deck of *n* cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can do one of two actions: 22 23 * take any two (not necessarily adjacent) cards with different colors and exchange them for a new card of the third color; 24 * take any two (not necessarily adjacent) cards with the same color and exchange them for a new card with that color. 25 26 She repeats this process until there is only one card left. What are the possible colors for the final card? 27 28 Input 29 30 The first line of the input contains a single integer *n* (1 ≤ *n* ≤ 200) — the total number of cards. 31 32 The next line contains a string *s* of length *n* — the colors of the cards. *s* contains only the characters 'B', 'G', and 'R', representing blue, green, and red, respectively. 33 34 Output 35 36 Print a single string of up to three characters — the possible colors of the final card (using the same symbols as the input) in alphabetical order. 37 38 Examples 39 40 Input 41 42 ``` 43 2 44 RB 45 ``` 46 47 Output 48 49 ``` 50 G 51 ``` 52 53 Input 54 55 ``` 56 3 57 GRG 58 ``` 59 60 Output 61 62 ``` 63 BR 64 ``` 65 66 Input 67 68 ``` 69 5 70 BBBBB 71 ``` 72 73 Output 74 75 ``` 76 B 77 ``` 78 79 Note 80 81 In the first sample, Catherine has one red card and one blue card, which she must exchange for a green card. 82 83 In the second sample, Catherine has two green cards and one red card. She has two options: she can exchange the two green cards for a green card, then exchange the new green card and the red card for a blue card. Alternatively, she can exchange a green and a red card for a blue card, then exchange the blue card and remaining green card for a red card. 84 85 In the third sample, Catherine only has blue cards, so she can only exchange them for more blue cards.