21934_RunLengthEncoding

2022-5-16 18:20| 发布者: Hocassian| 查看: 33| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505973030000-Problem List-采集的数据-后羿采集器.html

Pro.ID

21934

Title

Run Length Encoding

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21934

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    Your task is to write a program that performs a simple form of run-length encoding, as described by the rules below.

    Any sequence of between 2 to 9 identical characters is encoded by two characters. The first character is the length of the sequence, represented by one of the characters 2 through 9. The second character is the value of the repeated character. A sequence of more than 9 identical characters is dealt with by first encoding 9 characters, then the remaining ones.

    Any sequence of characters that does not contain consecutive repetitions of any characters is represented by a 1 character followed by the sequence of characters, terminated with another 1. If a 1 appears as part of the sequence, it is escaped with a 1, thus two 1 characters are output.

    输入

    The input consists of letters (both upper- and lower-case), digits, spaces, and punctuation. Every line is terminated with a newline character and no other characters appear in the input.

    输出

    Description

    Your task is to write a program that performs a simple form of run-length encoding, as described by the rules below.

    Any sequence of between 2 to 9 identical characters is encoded by two characters. The first character is the length of the sequence, represented by one of the characters 2 through 9. The second character is the value of the repeated character. A sequence of more than 9 identical characters is dealt with by first encoding 9 characters, then the remaining ones.

    Any sequence of characters that does not contain consecutive repetitions of any characters is represented by a 1 character followed by the sequence of characters, terminated with another 1. If a 1 appears as part of the sequence, it is escaped with a 1, thus two 1 characters are output.

    Input

    The input consists of letters (both upper- and lower-case), digits, spaces, and punctuation. Every line is terminated with a newline character and no other characters appear in the input.

    Output

    Each line in the input is encoded separately as described above. The newline at the end of each line is not encoded, but is passed directly to the output.

    Sample Input

    AAAAAABCCCC
    12344

    Sample Output

    6A1B14C
    11123124

    Source

    样例输入

    AAAAAABCCCC
    12344

    样例输出

    6A1B14C
    11123124

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部