AMSCO2 - Decipher the AMSCO cipher
Here you have to decipher the AMSCO cipher:
Due to A.M.SCOtt in the 19th century, it's an incomplete columnar transposition cipher with alternating single letters and digraphs. The first entry must be a digraph. In both even and odd periods the first column and the first row always alternate:
7 | 4 | 5 | 6 | 3 | 2 | 1 |
---|---|---|---|---|---|---|
RI | D | ER | S | ON | T | HE |
S | TO | R | MI | N | TO | T |
HI | S | HO | U | SE | W | EA |
R | EB | O | RN | J | IM | M |
OR | R | IS | O | N |
Input
N lines (N < 1000) Each line of the input contains the numeric key (permutation order of the columns) and a ciphertext. Ciphertext letters are in [A-Z] only with no punctuation. The keylength max is 9 and the length of the ciphertext is limited to 250. The last line ends with EOF.
Output
Output consist of exactly N lines of plaintexts with letters in [A-Z] with no spaces.
Example
Input: 7456321 HETEAMTTOWIMONNSEJNDTOSEBRERRHOOISSMIURNORISHIROR Output: RIDERSONTHESTORMINTOTHISHOUSEWEAREBORNJIMMORRISON
Input: 41325 CECRTEGLENPHPLUTNANTEIOMOWIRSITDDSINTNALINESAALEMHATGLRGR Output: INCOMPLETECOLUMNARWITHALTERNATINGSINGLELETTERSANDDIGRAPHS
hide comments
nadstratosfer:
2017-11-10 04:55:00
Reused AMSCO1 code in a really dumb way. Not too proud of this AC..
|
|
blazekid_dtu:
2016-03-31 20:52:45
doing AMSCO1 before this makes it a cakewalk. |
|
Daksh:
2015-12-28 16:18:41
just add 10 lines in AMSCO1 :D :) |
|
Nandu:
2014-12-13 09:02:53
AC in 1st go...:)
|
|
ROHIT RAJ:
2014-12-07 10:26:32
finally AC... feels great |
|
Diksha Jaiswal:
2014-12-03 18:40:12
1 WA cos of differences in compilers like ideone n d one used for judging in spoj...feels grt to see green light :D |
|
Jumpy:
2014-03-28 08:46:21
nice problem damn happy now |
|
shiv prasad chabarval:
2013-07-03 04:48:55
got AC in 1st go :)
|
|
Saurabh Jain:
2013-06-30 19:13:50
@legrand: I am getting WA again n again even though I verified my solution with a lot of test cases generated using amsco1 code. Can you please give me a hint for the occurrence of same?
|
|
Utsav Sinha:
2013-06-10 18:54:57
@legrand: please check my code, id - 9455124, it works for the test cases and many cases produced from AMSCO1, but gives wrong answer. thanks in advance...
|
Added by: | legrand |
Date: | 2013-04-04 |
Time limit: | 0.100s |
Source limit: | 10000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | ADA95 GAWK BASH C C++ 4.3.2 CPP C99 LISP sbcl LISP clisp FORTRAN GO HASK JAVA LUA OCAML PAS-GPC PAS-FPC PERL PHP PIKE PYTHON PYTHON3 PY_NBC RUBY SCM guile SCM qobi |
Resource: | classical ciphers |