#P1098. [NOIP 2007 提高组] 字符串的展开
[NOIP 2007 提高组] 字符串的展开
Description
In the preliminary round’s Junior “read the program and write the result” problem, we once gave an example of string expansion: if the input string contains substrings like d-h or 4-8, we treat them as shorthand. In the output, we replace the hyphen with a sequence of consecutively increasing letters or digits; that is, the two substrings above are output as defgh and 45678. In this problem, we add parameters to make the expansion more flexible. The conventions are as follows:
(1) Perform string expansion when the following condition is met: in the input string, there is a hyphen -, the characters on both sides are both lowercase letters or both digits, and according to ASCII order, the character on the right of the hyphen is strictly greater than the character on the left.
(2) Parameter : expansion mode. When , for letter substrings, fill with lowercase letters; when , for letter substrings, fill with uppercase letters. In both of these cases, the filling method for digit substrings is the same. When , regardless of whether it is a letter substring or a digit substring, fill with asterisks *, using the same number of asterisks as the number of characters that would be filled.
(3) Parameter : the repetition count of each filling character. means the same character is repeated times consecutively. For example, when , the substring d-h should expand to deeefffgggh. The characters on both sides of the hyphen remain unchanged.
(4) Parameter : whether to reverse the order. means keep the original order; means output in reverse order. Note that in this case the two endpoint characters are still excluded. For example, when , , , the substring d-h should expand to dggffeeh.
(5) If the character on the right of the hyphen is exactly the successor of the left character, delete only the hyphen; for example, d-e should be output as de, and 3-4 should be output as 34. If, according to ASCII order, the character on the right of the hyphen is less than or equal to the left character, keep the hyphen in the output; for example, d-d should be output as d-d, and 3-1 should be output as 3-1.
Input Format
Two lines.
Line : three positive integers separated by spaces, representing .
Line : one string consisting only of digits, lowercase letters, and hyphens -. There are no leading or trailing spaces.
Output Format
One line, the expanded string.
1 2 1
abcs-w1234-9s-4zz
abcsttuuvvw1234556677889s-4zz
2 3 2
a-d-d
aCCCBBBd-d
Hint
of the testdata satisfy: the string length does not exceed .
of the testdata satisfy: , , . The string length does not exceed .
NOIP 2007 Senior Problem 2.
Translated by ChatGPT 5
京公网安备 11011102002149号