티스토리 뷰
문제12 암호깨기 (Crypt Kicker)
A common but insecure method of encrypting text is to permute the letters of the alphabet. In other words, each letter of the alphabet is consistently replaced in the text by some other letter. To ensure that the encryption is reversible, no two letters are replaced by the same letter.
Your task is to decrypt several encoded lines of text, assuming that each line uses a different set of replacements, and that all words in the decrypted text are from a dictionary of known words.
Input
The input consists of a line containing an integer n, followed by n lowercase words, one per line, in alphabetical order. These nwords compose the dictionary of words which may appear in the decrypted text. Following the dictionary are several lines of input. Each line is encrypted as described above.
There are no more than 1,000 words in the dictionary. No word exceeds 16 letters. The encrypted lines contain only lower case letters and spaces and do not exceed 80 characters in length.
Output
Decrypt each line and print it to standard output. If there are multiple solutions, any one will do. If there is no solution, replace every letter of the alphabet by an asterisk.
Sample Input
6 and dick jane puff spot yertle bjvg xsb hxsn xsb qymm xsb rqat xsb pnetfn xxxx yyy zzzz www yyyy aaa bbbb ccc dddddd
Sample Output
dick and jane and puff and spot and yertle **** *** **** *** **** *** **** *** ******
# Source (My Solution)
ddddddddddddddddddd
'Computer > Algorithms' 카테고리의 다른 글
[기본] int 범위 초과 계산 (0) | 2021.04.15 |
---|---|
[Algorithms] Hash (0) | 2020.10.13 |
[Programming Challenges] 문제1 3n+1문제 (0) | 2017.07.05 |
[S/W] 간단한 큐(Queue)의 구현 (0) | 2015.12.12 |
[BackTracking] 체스 여왕말 놓기 (N-Queen Problem) (0) | 2015.12.06 |