HDU 1915 Arne Saknussemm

 

Arne Saknussemm

Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 216    Accepted Submission(s): 63

Problem Description
Following the account of Jules Verne, a scrambled message written by the middle age alchemist Arne Saknussemm, and deciphered by professor Lidenbrock, started the incredible travel to the center of the Earth. The scrambling procedure used by Arne is alike the procedure given below.

1. Take a non empty message M that contains letters from the English alphabet, digits, commas, dots, quotes (i.e. '), spaces and line breaks, and whose last character is different than space. For example, consider the following message whose translation reads "In Sneffels's crater descend brave traveler, and touch the center of the Earth".

In Sneffels craterem descende audasviator, et terrestre centrum attinges.

2. Choose an integral number 0<K≤length(M) and add trailing spaces to M such that the length of the resulting message, say M', is the least multiple of K. For K=19 and the message above, where length(M)=74 (including the 8 spaces and the line break that M contains), two trailing spaces are added yielding the message M' with length(M')=76.

3. Replace all the spaces from M' by the character _ (underscore) ; replace all the line breaks from M' by / (backslash), and then reverse the message. In our case:

__.segnitta_murtnec_ertserret_te_,rotaiv/sadua_ednecsed_meretarc_sleffenS_nI


4. Write the message that results from step 3 in a table with length(M')/K rows and K columns. The writing is column wise. For the given example, the message is written in a table with 76/19=4 rows and 19 columns as follows:
[缺少图片]

5. The strings of characters that correspond to the rows of the table are the fragments of the scrambled message. The 4 fragments of Arne's message given in step 1 are:

_etmneet_t/udsmt_fS.narctrtria_edrrlen
_gtuerr_,asaneeasf_si_t_seeovdec_ecenI


Write a program that deciphers non empty messages scrambled as described. The length of a message, before scrambling, is at most 1000 characters, including spaces and line breaks.

 

 

Input
The program input is from a text file where each data set corresponds to a scrambled message. A data set starts with an integer n, that shows the number of fragments of the scrambled message, and continues with n strings of characters that designate the fragments, in the order they appear in the table from step 4 of the scrambling procedure. Input data are separated by white-spaces and terminate with an end of file.

 

 

Output
The deciphered message must be printed on the standard output, from the beginning of a line and must be followed by an empty line as shown in the input/output sample below.

 

 

Sample Input
4  _etmneet_t/udsmt_fS
   _gtuerr_,asaneeasf_
   .narctrtria_edrrlen
   si_t_seeovdec_ecenI
11 e n r e V _ s e l u J
 

 

Sample Output
In Sneffels craterem descende audas
viator, et terrestre centrum attinges.

Jules Verne
 

 

Source

 

 

题解:

       悲剧的一题,今天才发现原来一直以来自己做的都没有错,空格也没有多输出,而是少输出末尾的空行。一大篇的废话,自己直接看的测试数据,发现第二个数据后面没有空行,错的就是这里。重点的我用红色标出来了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值