#K65522. Transform to Reverse

    ID: 32216 Type: Default 1000ms 256MiB

Transform to Reverse

Transform to Reverse

You are given a string ( s ) consisting of lowercase letters. Your task is to determine whether it is possible to transform ( s ) into its reverse by performing zero or more swaps, with the restriction that each character can be swapped at most once with an adjacent character.

More formally, let ( n=|s| ) denote the length of the string.

- If ( n ) is even, the transformation is possible if and only if the first ( \frac{n}{2} ) characters are equal to the reverse of the last ( \frac{n}{2} ) characters.

- If ( n ) is odd, ignore the middle character; the transformation is deemed possible if the first ( \lfloor \frac{n}{2} \rfloor ) characters are equal to the reverse of the last ( \lfloor \frac{n}{2} \rfloor ) characters.

Output "YES" if the transformation can be achieved and "NO" otherwise.

inputFormat

The input consists of a single line containing the string ( s ). The string is non-empty and contains only lowercase letters.

outputFormat

Output a single line: "YES" if it is possible to transform the string into its reverse as per the given conditions, or "NO" otherwise.## sample

abca
NO