시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 30 | 26 | 26 | 86.667% |
A text can be coded so that its letters are replaced by other letters. To do it we use a replacement table that can be created thus:
A word with different letters of English alphabet is chosen – a key word. An integer K less than or equal to 26 is chosen – a key number. A replacement table has two rows and 26 columns.
The upper row contains sorted letters of English alphabet (all of them). The key word is written letter by letter left to right in lower row starting from Kth position. Upon writing the last letter of the key word, we continue to write other letters (not appearing in the key word) sorted lexicographically. When a letter is written in the last (26th ) position of lower row, remaining letters are then written starting from the first position.
For example, if the key word is DUBROVNIK and the key number is 10, then the replacement table can be written as
An original text can be coded so that each letter is found in the first row and then replaced by a letter written below it.
Write a program that will using given key word and key number decode given coded text, i.e. find the original text.
The first line of input file contains a key word consisting of capital letters of English alphabet (A–Z). Length of a key word will be less than or equal to 26.
The second line of input file contains an integer K, 1 ≤ K ≤ 26, a key number.
The third line of input file contains coded text consisting of capital letters of English alphabet (A–Z). Length of coded text will be less than or equal to 100.
The first and only line of output file should contain decoded, i.e. original text.
NOVI 15 DTZNMNXAWT
VINODOLSKI
DUBROVNIK 10 SVPKVSVABZOMSRZY
DOBRODOSLINADMIH
ZAGREB 23 QYELREDEWEMLFNEIEP
OVAJZADATAKJELAGAN