NOIP '07 P2 - Expanding Strings

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 1.0s
Memory limit: 128M

Problem types

In the question of "reading the program to write the result" of the Junior group of the preliminary round, we gave an example of string expansion: if the input string contains a substring similar to d-h or 4-8, We take it as a shorthand. When outputting, replace the minus sign with a string of continuously increasing letters or numbers, that is, output the above two substrings as defgh and 45678 respectively. In this question, we make the string expansion more flexible by adding some parameter settings. The specific agreement is as follows:

  1. When encountering the following situation, it is necessary to expand the string: in the input string, a minus sign - appears, and both sides of the minus sign are lowercase letters or numbers, and in the order of ASCII codes, The character to the right of the minus sign is strictly greater than the character to the left.

  2. Parameter p_1: expansion method. When p_1=1, for alphabetic substrings, fill with lowercase letters; when p_1=2, for alphabetic substrings, fill with uppercase letters. The numeric substrings are padded the same way in both cases. When p_1=3, whether it is a alphabetic or numeric substring, it is filled with the same number of asterisks * as the number of letters to be filled.

  3. Parameter p_2: the number of repetitions of padding characters. p_2=k means that the same character should be filled k times consecutively. For example, when p_2=3, the substring d-h should expand to deeeffffgggh. The characters on either side of the minus sign are unchanged.

  4. Parameter p_3: Whether to change to reverse order: p_3=1 means to maintain the original order, p_3=2 means to use reverse order output, note that the characters at both ends of the minus sign are still not included. For example, when p_1=1, p_2=2, p_3=2, the substring d-h should be expanded to dggffeeh.

  5. If the character on the right of the minus sign happens to be the successor of the character on the left, only delete the minus sign in the middle, for example: d-e should be output as de, and 3-4 should be output as 34. If the character to the right of the minus sign is less than or equal to the character to the left in ASCII code order, keep the minus sign in the middle, for example: d-d should be output as d-d, 3-1 should be output as 3-1.

Input Specification

Two lines:

  • Line 1 contains 3 positive integers, representing the parameters p_1, p_2, p_3.
  • Line 2 is a string consisting only of numbers, lowercase letters, and a minus sign -. It's guaranteed that the line has no trailing spaces.

Output Specification

One line, the expanded string.

Sample Input 1

1 2 1 
abcs-w1234-9s-4zz

Sample Output 1

abcsttuuvvw1234556677889s-4zz

Sample Input 2

2 3 2 
a-d-d

Sample Output 2

aCCCBBBd-d

Sample Input 3

3 4 2 
di-jkstra2-6

Sample Output 3

dijkstra2************6

Constraints

40\% of the data satisfy that the length of string is at most 5.

100\% of the data satisfy 1 \leq p_1 \leq 3, 1 \leq p_2 \leq 8, 1 \leq p_3 \leq 2, and the length of the string is at most 100.


Comments

There are no comments at the moment.