#C14882. Reverse and Palindrome Check

    ID: 44580 Type: Default 1000ms 256MiB

Reverse and Palindrome Check

Reverse and Palindrome Check

In this problem, you are given a string (S) that may include letters, digits, spaces, and punctuation marks. Your task is to perform two operations on the string:

  1. Reverse the string and output the reversed version exactly as it appears (i.e. maintaining the case of each character).

  2. Check if the string is a palindrome when considering only alphanumeric characters and ignoring letter case. In other words, let (s') be the string obtained by removing all non-alphanumeric characters from (S) and converting the result to lowercase. The string (S) is considered a palindrome if (s' = (s')^R), where ((s')^R) is the reverse of (s').

For example, the string "Madam" when reversed is "madaM" and, after cleaning, becomes "madam" which is a palindrome. Similarly, "A man, a plan, a canal, Panama!" is a palindrome after cleaning, even though its reversed original string is different.

inputFormat

Input is read from standard input (stdin) as a single line containing the string (S). The string may contain spaces, punctuation, and can be empty.

outputFormat

Output two lines to standard output (stdout):

  1. The first line should contain the reversed string.
  2. The second line should be either 'True' or 'False', indicating whether the string is a palindrome after removing all non-alphanumeric characters and converting to lowercase (i.e. checking if (s' = (s')^R)).## sample
hello
olleh

False

</p>