VC驿站

 找回密码
 加入驿站

QQ登录

只需一步,快速开始

搜索
查看: 1105|回复: 0

Encode and Decode

[复制链接]
09_avatar_middle
online_moderator 发表于 2010-4-11 21:07:10 | 显示全部楼层 |阅读模式
本帖最后由 haoran 于 2010-4-11 21:13 编辑

Mr. Encript is working on information transmission. One part of his job is to encode and decode an article. The encoding part is really simple:

1.  Give a string of characters at first. This string should contain all the characters in the article. In this string, each character will appear only once. Each character has a code index. The character’s index is this character's position in the string, starts from position 0.
2.  Assume character C is at the position 0 of the string, and then find out how many C in the article to be encoded, and record the positions C appear in the article. Output the number of character C, and then output the positions, separated by a blank space.
3.  Process the next character (at the position 1) of the string as step 2. Repeat until process the whole string.
4.  The new number sequence is the code wanted.

For example, given a index string:
String        A        B        C        D                 +
Position        0        1        2        3        4        5

and a article to be encoded:
Article        C        A        B                 C        A        D
Position        0        1        2        3        4        5        6

The code we can get is:
2        1        5        1        2        2        0        4        1        6        1        3        0
A                        B                C                        D                                 +

Mr. Encript needs someone to finish the decoding part. So he gives the decoding job to you. You should write a program which can output the article with index string and the code sequence.


这是南开大学的ACM协会出的题目,大家可以看一下!




上一篇:[无奖](放假回老家,没时间上网了)帮朋友一个忙
下一篇:Study Room
您需要登录后才可以回帖 登录 | 加入驿站 qq_login

本版积分规则

关闭

站长提醒上一条 /2 下一条

QQ|小黑屋|手机版|VC驿站 ( 辽ICP备09019393号tongdun|网站地图wx_jqr

GMT+8, 2019-1-18 08:26

Powered by Discuz! X3.4

© 2009-2018 cctry.com

快速回复 返回顶部 返回列表