UVa 401-palindromes

Source: Internet
Author: User

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

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

A mirrored string is a string for which when each of the elements of the string was changed to its reverse (if it had a rev Erse) and the string is read backwards the result is the same as the original string. For example, the string "3AIAE" was a mirrored string because "a" and "I" are their own reverses, and "3" and "E" were 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 was read backwards, the string is the same as the Origi NAL and because if each of the characters are replaced by it reverse and the result is read backwards, the result is the S Ame as the original string. Of course, "A", "T", "O", and "Y" is all their own reverses.

A List of all valid characters and their reverses are 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 that O (zero) and 0 (the letter) was 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 the which would consist of one to twenty valid characters. There'll be is 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.

CRITERIA for STRING
"–is not a palindrome."
If the string is not a palindrome and is not a mirrored string
"–is a regular palindrome."
If the string is a palindrome and was not a mirrored string
"–is a mirrored string."
If the string is not a palindrome and is a mirrored string
"–is a mirrored palindrome."
If the string is a palindrome and is a mirrored string
Note the output line was to include the-' s and spacing exactly as shown in the table above and demonstrated in the Sa Mple Output below.

In addition, after the 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.

#include <iostream>#include <sstream>#include <iomanip>#include <vector>#include <deque>#include <list>#include <set>#include <map>#include <stack>#include <queue>#include <bitset>#include <string>#include <numeric>#include <algorithm>#include <functional>#include <iterator>#include <cstdio>#include <cstring>#include <cmath>#include <cstdlib>#include <cctype>#include <complex>#include <ctime>#define INF 0x3f3f3f3f#define EPS 1e-6#define P (x) printf ("%d\n", x)#define K (x) printf ("Case%d:", ++x)#define MES (x, D) memset (x, D, sizeof (x))#define S (x) scanf ("%d", &x)typedef Long LongLL;Const DoublePI =ACOs(-1.0);Const Long LongMoD =1e9+7;using namespace STD;Const Char* S1 = {"A 3 HIL JM O 2tuvwxy51se Z 8"};Const Char* s2[] = {"--is not a palindrome.","--is a regular palindrome.","--is a mirrored string.","--is a mirrored palindrome."};CharRCharCH) {if(Isalpha(CH))returnS1[ch-' A '];returnS1[ch-' 0 '+ -];}Chars[1005];intMain () {//freopen ("Int.txt", "R", stdin);    //freopen ("OUT.txt", "w", stdout);     while(scanf('%s ', s) = =1)    {intLen =strlen(s);intK1 =1, K2 =1; for(inti =0; i < (Len +1) /2; i++) {if(S[i]! = s[len-i-1]) K1 =0;if(R (s[i])! = s[len-i-1]) K2 =0; }printf("%s%s\n\n", S,S2[K2 *2+ K1]); }return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

UVa 401-palindromes

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.