#C6064. Palindrome Formation with 'a' Insertions

    ID: 49783 Type: Default 1000ms 256MiB

Palindrome Formation with 'a' Insertions

Palindrome Formation with 'a' Insertions

You are given a string s consisting of lowercase English letters. Your task is to determine whether it is possible to rearrange the characters of the string and, if necessary, add additional characters 'a' so that the resulting string is a palindrome.

A palindrome is a string that reads the same forward and backward. In mathematical terms, a string of length \(n\) is a palindrome if for all \(i\) (\(1 \le i \le n\)), the \(i\)-th character from the beginning is equal to the \(i\)-th character from the end.

Note that adding additional characters is allowed only for the letter 'a'. However, the solution approach provided ignores this addition explicitly and checks whether the string can be rearranged as-is into a palindrome by verifying that at most one character appears an odd number of times.

For example:

  • Input: civic → Output: True
  • Input: ivicc → Output: True
  • Input: hello → Output: False
  • Input: aac → Output: True

inputFormat

The input is given from standard input and consists of a single line containing the string s. The string contains only lowercase English letters.

outputFormat

Output a single line to standard output. If it is possible to rearrange the string (and add extra 'a' characters if needed) to form a palindrome, print True; otherwise, print False.

## sample
civic
True