SPOJ Problem Set (classical)

3378. Mirrored Pairs

Problem code: MIRRORED

The letters b and d are mirror images of each other, as are p and q. No other pairs of letters are mirrors, except for letters like H that are mirrors of themselves, and what’s the interest in a pair that’s just two of the same letter? We refuse to count self-mirrors as mirrored pairs.


Input is a list of lines with two characters on each line. Your program should end immediately when it encounters a line with two spaces.


The first line of output should contain only Ready. For each pair of characters (prior to a pair of spaces), print the line Mirrored pair if the characters are mirrors, otherwise print the line Ordinary pair.



Ordinary pair
Mirrored pair
Ordinary pair
Mirrored pair

All Submissions
Best Solutions

Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Apr 08, 2011

Languages Allowed:

Comments (Search)


is pq and bd count as mirrored

can somone tell me why there is a pq after the two-spaced line?

Don't mind it. It's just to specify that the program should break after a line with 2 spaces.

why do i keep getting no such elements exception when i submit it and why do i still earn points? does it change if i get it right or wrong? also, i keep getting 0 on the last test case, so can anyone help? thanks.

is there a extra pair after the two-lined space in the test cases? if so, should i add a extra input for it?

also, i don't get any error with or without the extra pair after the two spaced line. so is it something wrong with the test case or what?

Your program should break as soon as it encounters the two-spaced line.
Your three comments could easily fit into one.

thanks for the information, so can you answer my questions now? not to be rude or anything.
also, it is still like that with out the extra input.
hopefully someone will answer soon because it is 8 pm and i need to hand in the homework tomorrow.


I keep getting wrong answers, but I don't know the source of these of these errors. All the test cases do work for me, and when 2 spaces are input, the program does end.I have considered all variations of mirrored pairs, so I don't see where I went wrong, unless uppercases are included. I have been reading the comments, and it seems there was an error in the past.
Could this (or something similar) be it? Or am I just missing some obvious problem?

I honestly have no idea what im doing wrong

Does it work on the samples fine? Try it on ideone. Specifically, you are checking a[0] without ever initializing a, and I'm not sure how well std::string handles that sort of thing

Works fine there

FML i realized what was wrong. I had a capital P for pair.


[he's NOT my friend]


[he's my friend]

Your program should end immediately when it encounters a line with two spaces.

I don't get it. How do I do it in C++?

getline(cin, stringname);

then you can just check if
stringname == "  "

Why am I getting 0/300?

Look at the sample output very carefully.

Hi! I'm having trouble trying to find out how to automatically end the program (in python 3) when two spaces occur. Please help me!

Use the break keyword. Ex: "if chars == " ":

That will end a while loop.

are things like 'mm','nn',and 'ii' considered mirrored pairs?

We refuse to count self-mirrors as mirrored pairs.

Thanks!! I guess I didn't read the question carefully enough...


[he's my friend]

How can this simple program take too long to evaluate? Only one of the test cases though. Can someone help me with this?

There's an end condition that you're not considering. Hint: you probably won't be able to test this via console.

Isnt the end condition two spaces in a line?

Sorry about that. Again, I guess I didn't look at your code carefully enough.

This was a problem on our end. I fixed it and rejudged, and you're now getting AC. :-)

Thanks for your fast help! :)