#K4081. String Decompression

    ID: 26725 Type: Default 1000ms 256MiB

String Decompression

String Decompression

You are given an encoded string. The encoding rule is: k[string], where the string inside the square brackets is repeated exactly k times. Note that k is guaranteed to be a positive integer. The input string may contain nested encoded patterns.

Your task is to decompress the string and output the resulting decomposition.

Example:

  • Input: 3[a]2[bc]
  • Output: aaabcbc

Handle nested expressions appropriately. You can assume that the format of the input is always valid.

inputFormat

The input is a single line string representing the encoded sequence. It may include digits, characters, and bracket pairs denoting repetition.

outputFormat

Output the decompressed string corresponding to the encoded input.## sample

3[a]2[bc]
aaabcbc