ZQUOJ1401 Substitution Cypher解题报告

来源:互联网 发布:jquery 数据列表插件 编辑:程序博客网 时间:2024/04/28 16:03

Substitution Cypher

memory limit: 65536KB time limit: 500MS

accept: 19 submit: 32

Description

Substitution cyphers are the simplest of cyphers where the letters of one alphabet are substituted for the letters of another alphabet. In one form or another, they've been in use for over 2000 years.

Input

A line containing the plaintext alphabet
A line containing the substitution alphabet
Several lines of text

Output

A line containing the substitution alphabet
A line containing the plaintext alphabet
The converted lines of text

Please note: All lines will be at most 64 characters, plus a trailing end-of-line character. Pass through all characters not found in the plaintext alphabet.

Sample Input

abcdefghijklmnopqrstuvwxyz
zyxwvutsrqponmlkjihgfedcba
Shar's Birthday:
The birthday is October 6th, but the party will be Saturday,
October 5. It's my 24th birthday and the first one in some
years for which I've been employed. Plus, I have new clothes.
So I have cause to celebrate. More importantly, though,
we've cleaned the house! The address is 506-D Albert Street.
Extra enticement for CS geeks: there are several systems in
the house, and the party is conveniently scheduled for 3 hours
after the second CSC programming contest ends (not to mention,
within easy walking distance)!

Sample Output

zyxwvutsrqponmlkjihgfedcba
abcdefghijklmnopqrstuvwxyz
Sszi'h Brigswzb:
Tsv yrigswzb rh Oxglyvi 6gs, yfg gsv kzigb droo yv Szgfiwzb,
Oxglyvi 5.  Ig'h nb 24gs yrigswzb zmw gsv urihg lmv rm hlnv 
bvzih uli dsrxs I'ev yvvm vnkolbvw.  Pofh, I szev mvd xolgsvh.
Sl I szev xzfhv gl xvovyizgv.  Mliv rnkligzmgob, gslfts, 
dv'ev xovzmvw gsv slfhv!  Tsv zwwivhh rh 506-D Aoyvig Sgivvg.
Ecgiz vmgrxvnvmg uli CS tvvph:  gsviv ziv hvevizo hbhgvnh rm
gsv slfhv, zmw gsv kzigb rh xlmevmrvmgob hxsvwfovw uli 3 slfih
zugvi gsv hvxlmw CSC kiltiznnrmt xlmgvhg vmwh (mlg gl nvmgrlm,
drgsrm vzhb dzoprmt wrhgzmxv)!

Source

ZQUCPC个人赛5

Author

Waterloo local

 

 

题意:

给出对应字母的转换表,转换文段。

 

错误做法:

这是一道水题,一开始错了一次,是因为没解决好输入问题,,而且题目看漏了一句,输出的前两行为转换字母表转换后的字母行。

 

问题的分析与解题思路:

给出两行字母,第一行为原字母,第二行的字母为第一行对应字母转换后的字母。整个文段都需要转换。

 

AC方法和数据结构:

先将原字母表及相对应的转换字母表保存起来,然后对每个字符在原字母表中遍历,如果该字母需要转换,则输出转换字母表中对应的字母,否则输出原字母。

 

AC代码:

算法复杂度分析:

时间复杂度是o(n)

 

总结:

特别注意输入。

 

 

原创粉丝点击