| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 572 人关注过本帖
标题:北京大学acm1051题
只看楼主 加入收藏
吕亚亚
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-4-23
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
北京大学acm1051题
Language:
P,MTHBGWB
Time Limit: 1000MS        Memory Limit: 10000K
Total Submissions: 7056        Accepted: 4072
Description

Morse code represents characters as variable length sequences of dots and dashes. In practice, characters in a message are delimited by short pauses. The following table shows the Morse code sequences:
A    .-    H    ....    O    ---    V    ...-
B    -...    I    ..    P    .--.    W    .--
C    -.-.    J    .---    Q    --.-    X    -..-
D    -..    K    -.-    R    .-.    Y    -.--
E    .    L    .-..    S    ...    Z    --..
F    ..-.    M    --    T    -          
G    --.    N    -.    U    ..-          

Note that four dot-dash combinations are unassigned. For the purposes of this problem we will assign them as follows (these are not the assignments for actual Morse code):
underscore    ..--    period    ---.
comma    .-.-    question mark    ----

Thus, the message "ACM_GREATER_NY_REGION" is encoded as:
.- -.-. -- ..-- --. .-. . .- - . .-. ..-- -. -.-- ..-- .-. . --. .. --- -.
M.E. Ohaver proposed an encryption scheme based on mutilating Morse code. Her scheme replaces the pauses between letters, necessary because Morse is a variable-length encoding that is not prefix-free, with a string that identifies the number of dots and dashes in each. For example, consider the message ".--.-.--". Without knowing where the pauses should be, this could be "ACM", "ANK", or several other possibilities. If we add length information, however, ".--.-.--242", then the code is unabiguous.
Ohaver's scheme has three steps, the same for encryption and decryption:
1.    Convert the text to Morse code without pauses but with a string of numbers to indicate code lengths
2.    Reverse the string of numbers
3.    Convert the dots and dashes back into to text using the reversed string of numbers as code lengths
As an example, consider the encrypted message "AKADTOF_IBOETATUK_IJN". Converting to Morse code with a length string yields ".--.-.--..----..-...--..-...---.-.--..--.-..--...----.232313442431121334242". Reversing the numbers and decoding yields the original message "ACM_GREATER_NY_REGION".
Input

This problem requires that you implement Ohaver's encoding algorithm. The input will consist of several messages encoded with Ohaver's algorithm. The first line of the input is an integer n that specifies the number of test cases. The following n lines contain one message per line. Each message will use only the twenty-six capital letters, underscores, commas, periods, and question marks. Messages will not exceed 100 characters in length.
Output

For each message in the input, output the line number starting in column one, a colon, a space, and then the decoded message. The output format must be adhered to precisely.
Sample Input

5
AKADTOF_IBOETATUK_IJN
PUEL
QEWOISE.EIVCAEFNRXTBELYTGD.
?EJHUT.TSMYGW?EJHOT
DSU.XFNCJEVE.OE_UJDXNO_YHU?VIDWDHPDJIKXZT?E
Sample Output

1: ACM_GREATER_NY_REGION
2: PERL
3: QUOTH_THE_RAVEN,_NEVERMORE.
4: TO_BE_OR_NOT_TO_BE?
5: THE_QUICK_BROWN_FOX_JUMPS_OVER_THE_LAZY_DOG
Source
搜索更多相关主题的帖子: 北京大学 represents following practice message 
2013-11-12 21:55
liu229118351
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:83
专家分:101
注 册:2013-10-23
收藏
得分:7 
表示看不懂。。这个是神马啊。。。

单曲循环,需要信心+耐心+恒心
2013-11-12 21:57
吕亚亚
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-4-23
收藏
得分:0 
回复 2楼 liu229118351
这是北京大学acm的1051题http://真心的希望可以解出来
2013-11-12 22:02
czz5242199
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:4
帖 子:660
专家分:2400
注 册:2011-10-26
收藏
得分:7 
按照它的规则解密就好了,有什么难的啊
2013-11-12 23:39
韶志
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:斗气大陆
等 级:贵宾
威 望:44
帖 子:2223
专家分:13592
注 册:2013-3-22
收藏
得分:7 
很少做ACM   
英文看不懂

三十年河东,三十年河西,莫欺少年穷!
2013-11-19 00:13
快速回复:北京大学acm1051题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022232 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved