UVa 401 palindromes: string matching

Source: Internet
Author: User
Tags time limit valid

401-palindromes

Time limit:3.000 seconds

Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem &problem=342

A regular palindrome is a string of numbers or letters the same as forward. For example, the string "ABCDEDCBA" was a palindrome because it is the same when the ' string is ' read from ' to ' right as W Hen the string is read from right to left.

A mirrored string is a string for which then each of the elements of the the string is changed to its reverse (if it has a rev Erse) and the string is read backwards the the same as the original string. For example, the string ' 3AIAE ' is a mirrored string because ' a ' and ' I ' are their own reverses, and ' 3 ' and ' E ' are each Others ' reverses.

A mirrored palindrome is a string that meets the criteria of a regular palindrome and the criteria of a mirrored string. The string "Atoyota" is a mirrored palindrome because if the string are read backwards, the string is the same as the Origi NAL and because if each of the characters are replaced by their reverse and the result is read backwards, the Ame as the original string. Of course, "A", "T", "O", and "Y" are all their own reverses.

A List of all valid characters and their reverses is as follows.

Character Reverse Character Reverse Character Reverse

A a M M y y

B N Z 5

C o O 1 1

D P 2 S

E 3 Q 3 E

F R 4

G S 2 5 Z

H T T 6

I I u u 7

J L v v 8 8

K W W 9

L J x x

Note this O (zero) and 0 (the letter) are considered the same character and therefore only the letter "0" is a valid Chara Cter.

Input

Input consists of strings (one per line) each of which would consist of one to twenty valid characters. There'll be no. Invalid characters in any of the strings. Your program should read to the end of file.

Output

For each input string, you should print the string starting in column 1 immediately followed by exactly one of the FOLLOWI ng strings.

The "Output line" is to include the-"s" and spacing exactly as shown in the table above and demonstrated in the Sa Mple Output below.

In addition, after each output line, you must print a empty line.

Sample Input

Notapalindrome

Isapalinilapasi

2a3meas

Atoyota

Sample Output

Notapalindrome-is not a palindrome.

Isapalinilapasi-is a regular palindrome.

2a3meas-is a mirrored string.

Atoyota-is a mirrored palindrome.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.