Alun, you checked for mirroring and palindroming, both things at the same time. I think it's easier if you check independently:
[cpp]int Len = strlen(S);
bool IsPal = true, IsMir = true;
for (int i = 0; i < Len; i++) {
char C = S;
char Op = S[Len-1-i];
if (C != Op) IsPal = false;
if (C != Rev(Op)) IsMir = false;
}
[/cpp]
One thing that bored me about this problem is this sentence:
"A mirrored string is a string for which when each of the elements of the string is changed to its reverse (if it has a reverse) and the string is read backwards the result is the same as the original string."
This sentence is ambuguous. What if it does not have a reverse? Should I not replace that character, should I replace it with blank space or all characters must have an reverse for that input to be mirrored?
The sample input does not answer my question, but I discovered the answer by sending mutiple codes until I got Accepted.
I replaced characters that didn't have a reverse with blank space.
I solve 4 problems per day, then I expend 4 days stuck in a single problem. But I think I'm doing well... ID 37180
Okay... Thanks for that. I made some stupid assumptions about ASCII conversions :/ But I have a different set of problems now. I suppose I have to sort this out the hard way :/
NOTAPALINDROME -- is not a palindrome.
ISAPALINILAPASI -- is a regular palindrome.
2A3MEAS -- is a mirrored string.
ATOYOTA -- is a mirrored palindrome.
MAIAM -- is a mirrored palindrome.
123ESI -- is not a palindrome.
123ES1 -- is a mirrored string.
DEO3D -- is a mirrored string.
9339 -- is a regular palindrome.
A -- is a mirrored palindrome.
B -- is a regular palindrome.
E -- is a mirrored palindrome.
M -- is a mirrored palindrome.
1 -- is a mirrored palindrome.
3 -- is a mirrored palindrome.
2 -- is a mirrored palindrome.
4 -- is a regular palindrome.
Is everything correct? Why do I still get a WA? Please help me
Edit: The formatting is correct in the actual output
since sohel told pointed out that program is not working for B ,E you
probably added this line [c] if(n<2) return 0; [/c] to fix it ,now it doesnt work for 8 ! ..its an easy program you need to test properly
btw i re-wrote the solution if u still get WA i can send that ..