NotebookProblem code: CSEA4 |
All submissions for this problem are available.
--I just bought Leonardo's secret notebook!
Rare object collector Stan Ucker was really agitated
but his friend, special investigator Sarah Kepticwas
unimpressed.
--How do you know it is genuine?
-- Oh, it must be, at that price. And it is written in
the da Vinci code.
Sarah browsed a few of the pages. It was obvious to
her that the code was a substitution cipher, where
each letter of the alphabet had been substituted by
another letter.
--Leonardo would have written the plain-text and
left it to his assistant to encrypt, she said. And he
must have supplied the substitution alphabet to be
used. If we are lucky, we can find it on the back
cover!
She turned up the last page and, lo and behold, there was a single line of all 26 letters of the
alphabet:
QWERTYUIOPASDFGHJKLZXCVBNM
-- This may be Leonardo's instructions meaning that each A in the plain-text was to be
replaced by Q, each B withW, etcetera. Let us see...
To their disappointment, they soon saw that this could not be the substitution that was used
in the book. Suddenly, Stan brightened.
-- Maybe Leonardo really wrote the substitution alphabet on the last page, and by mistake
his assistant coded that line as he had coded the rest of the book. So the line we have here is
the result of applying some permutation TWICE to the ordinary alphabet!
Sarah took out her laptop computer and coded fiercely for a few minutes. Then she turned
to Stan with a sympathetic expression.
-- No, that couldn't be it. I am afraid that you have been duped again, my friend. In all
probability, the book is a fake.
Write a program that takes a permutation of the English alphabet as input and decides if it
may be the result of performing some permutation twice.
Input
The input begins with a positive number on a line of its own telling the number of test cases (at most 500). Then for each test case there is one line containing a permutation of the 26 capital letters of the English alphabet.
Output
For each test case, output one line containing Yes if the given permutation can result from applying some permutation twice on the original alphabet string ABC...XYZ, otherwise output No.
Example
Input: 2 QWERTYUIOPASDFGHJKLZXCVBNM ABCDEFGHIJKLMNOPQRSTUVWXYZ Output: No Yes
| Author: | cseaiitg |
| Date Added: | 20-09-2010 |
| Time Limit: | 1 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions
