2015 C Programming Contest (Week 15)

From: 2015-06-10 15:30:00 To: 2015-06-10 16:50:00 Now: 2024-11-21 21:42:21 Status: Public

D - WCSPC 2015 D

Time Limit: 1s Memory Limit: 128MB

Submissions: 137 Solved: 42
Description

허술하게 암호화된 문장을 원래 문장으로 복호화하는 문제입니다.

사용된 암호화 방식은 다음과 같습니다.

- 알파뱃 치환 방식이 사용됩니다. 각각의 알파뱃은 대응되는 알파뱃을 가집니다. 예를 들어, ‘b’‘t’(b->t), ‘e’‘r’(e->r) 대응될 경우, “bee”“trr”로 치환됩니다. 대응은 1:1의 대응관계를 가집니다.

- 본 문제에서는 알파뱃 소문자만 치환됩니다. 다른 ascii 문자는 원본문장과 암호화된 문장에서 동일하게 나타납니다.

, 복호화를 위해 여러분께 제공되는 정보는 다음과 같습니다.

1. 원본 문장의 알파뱃 빈도

- 원본 문장의 알파뱃 (a ~ z)에 대한 발생 빈도가 제공됩니다. 원본 문장에서 나타나는 모든 알파뱃은 서로 다른 발생 빈도를 가집니다.

2. 암호화된 문장

- 대응되는 알파뱃으로 암호화 된 문장이 주어집니다.

위 정보를 이용하여 원본 문장으로 복호화를 진행해 봅시다!

 

(ENG)
This is a problem of decoding a poorly encrypted sentences into original one.

Encryption method is the following.

- Substitution alphabet is used. Each alphabet has a corresponding alphabet. For example, if ‘b’ correspond to ‘t’ (b->t) and ‘e’ correspond to ‘r’ (e->r), “bee” is substituted as “trr”. Each letter has an one-to-one correspondence.

- In this problem, only the lower case alphabets are substituted. Other ascii characters are shown same in both original and encrypted sentences.

Now, followings are the information that are given for decoding.

1. Frequency of alphabet in original sentences.

- Frequency of alphabet(a ~ z) in original sentences are given. Each alphabet has different frequency from each other.

2. Encrypted sentences

- Encrypted sentences with corresponding alphabet is given.

Lets decode it into original sentences with given information!

 

Input

Line 1 ~ 26 : 알파뱃 별 원본문장에서의 발생 빈도

- 발생 빈도는 100000을 넘지 않음

Line 27 ~ EOF : 암호화된 문장

- 문장은 최대 1000개의 단어로 구성됨.

- 각 단어는 100글자를 넘지 않음.

 

(ENG)
Line 1 ~ 26 : Frequency of each alphabet in original sentences.

- Frequency does not exceed 100000.

Line 27 ~ EOF : Encrypted sentences.

- Sentences are consisted with maximum 1000 words.

- Each words are maximum 100 letters.

Output

암호화된 문장 각각에 대해 복호화된 문장을 출력

 

(ENG)
Print out decoded(original) sentence for each encrypted sentence.

Sample Input
a 51
b 6
c 26
d 25
e 92
f 16
g 20
h 31
i 50
j 0
k 1
l 18
m 22
n 61
o 45
p 14
q 2
r 52
s 33
t 55
u 11
v 5
w 12
x 0
y 15
z 0
hwssi giksv
okfexinkaehf ekbik xi xhw civwkd anw gaq wjjwoxbuwsf qfdidfcirq gbxh wdokfexbid, xhw oiduwkqbid ij bdjikcaxbid jkic a kwavaysw qxaxw xi aeeakwdx didqwdqw.
xhw ikbnbdaxik ij ad wdokfexwv cwqqanw qhakwv xhw vwoivbdn xwohdbtrw dwwvwv xi kwoiuwk xhw ikbnbdas bdjikcaxbid idsf gbxh bdxwdvwv kwobebwdxq, xhwkwyf ekwosrvbdn rdgadxwv ewkqidq jkic vibdn xhw qacw.
ad wdbnca caohbdw gaq adf ij qwuwkas wswoxki-cwohadboas kixik obehwk caohbdwq rqwv bd xhw xgwdxbwxh owdxrkf jik wdobehwkbdn adv vwobehwkbdn qwokwx cwqqanwq. wdbnca gaq bduwdxwv yf xhw nwkcad wdnbdwwk akxhrk qohwkybrq ax xhw wdv ij giksv gak b.
xhw 2014 jbsc xhw bcbxaxbid nacw xwssq xhw qxikf ij asad xrkbdn adv hbq axxwcexq xi okaom xhw wdbnca caohbdw oivw vrkbdn giksv gak bb.
yw oakwjrs jik aqqaqqbdaxik
nwdwkaxwv yf xawcbd fjt
Sample Output
hello world
cryptography prior to the modern age was effectively synonymous with encryption, the conversion of information from a readable state to apparent nonsense.
the originator of an encrypted message shared the decoding technique needed to recover the original information only with intended recipients, thereby precluding unwanted persons from doing the same.
an enigma machine was any of several electro-mechanical rotor cipher machines used in the twentieth century for enciphering and deciphering secret messages. enigma was invented by the german engineer arthur scherbius at the end of world war i.
the 2014 film the imitation game tells the story of alan turing and his attempts to crack the enigma machine code during world war ii.
be careful for assassinator
generated by taemin yfq