QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 64 MB Total points: 20

#23752. String Operation

Statistics

Problem Statement

When a string consisting only of digits from $0$ to $9$ is given, consider the operation of creating a new string from that string according to the following rule. Read the given string character by character ($1$ character at a time) in order from the left end, and when the same digit $a$ continues $r$ times, write out the count $r$ and the digit $a$ in this order without separating them by spaces. Even if writing out occurs multiple times along the way, reading up to the right end of the given string and finishing the last writing out is counted altogether as $1$ operation. From the $2$-nd operation onward, perform the same operation using the string written out by the previous operation as the given string. For example, when the string 122244 is given, from the left end in order there are $1$ of $1$, $3$ of $2$, and $2$ of $4$, so the string obtained by $1$ operation is 113224; in the case of 44444444444 ($11$ of $4$), the obtained string is 114.

Write a program that outputs the string obtained by performing the above operation $n$ times on a given string of $100$ characters or fewer. Here, assume $n \le 20$.

The name of the input file is input.txt. input.txt consists of $2$ lines: the $1$-st line contains the number of operations $n$, and the $2$-nd line contains the initial string.

The name of the output file is output.txt. output.txt consists of $1$ line, and a newline must be inserted after the string obtained by performing the specified number of operations.

Sample 1

Sample Input 1

5
11

Sample Output 1

13112221

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.