#K41677. Gemstone Palindromic Arrangement
Gemstone Palindromic Arrangement
Gemstone Palindromic Arrangement
In this problem, you are given ( n ) gemstones along with their associated colors. Your task is to determine whether it is possible to rearrange these gemstones such that the resulting sequence forms a palindrome. A sequence is palindromic if it reads the same backward as forward. A necessary and sufficient condition to form a palindrome is that at most one color has an odd frequency, which can be represented by the formula: ( \text{odd_count} \leq 1 ). Input will be provided via standard input and output must be written to standard output.
inputFormat
The input consists of two lines:
- The first line contains a single integer ( n ) representing the number of gemstones.
- The second line contains ( n ) space-separated strings, each representing the color of a gemstone.
outputFormat
Output a single line containing either "POSSIBLE" if a palindromic arrangement can be formed, or "IMPOSSIBLE" otherwise.## sample
3
blue red blue
POSSIBLE