#C1311. Palindrome Rearrangement with Optional Removal

    ID: 42612 Type: Default 1000ms 256MiB

Palindrome Rearrangement with Optional Removal

Palindrome Rearrangement with Optional Removal

Given a binary string of length (N) consisting only of '0's and '1's, determine whether it is possible to rearrange its characters into a palindrome by performing the allowed operations, which include the optional removal of at most one character if necessary. A string is a palindrome if it reads the same forwards and backwards. For a string of even length, all characters must appear an even number of times, while for a string of odd length, at most one character may appear an odd number of times.

Output Yes if it is possible to form such a palindrome under the given conditions; otherwise, output No.

Note: The input is read from standard input (stdin) and the output should be written to standard output (stdout). All formulas are provided in (\LaTeX) format.

inputFormat

The input consists of two lines. The first line contains an integer (N), which represents the length of the binary string. The second line contains the binary string itself, composed solely of the characters '0' and '1'.

outputFormat

Print a single line to the standard output (stdout) containing either Yes or No. Yes indicates that it is possible to rearrange the characters (with at most one removal when needed) to form a palindrome, and No indicates that it is not possible.## sample

4
1100
Yes

</p>