Problem hidden
This problem was hidden by Editorial Board member probably because it has incorrect language version or invalid test data, or description of the problem is not clear.
Problem hidden on 2014-03-26 10:43:29 by Francky

CW - Compressed Words


Compressed Words

Description

Helen has come up with a way to shorten the length of the messages send to their counter parts in the past.  Helen considers only individual words, and uses the following rules to define a "shortened word":

  1. a single, lower-case letter is a compressed word
  2. (e1 e2 ... et n) where t and n are non-negative integers and ei is a compressed word.

You should observe that a compressed word of one character is the same as an uncompressed word. To uncompress the compressed word (e1 e2 ... et n) we uncompress each ei , concatenate those uncompressed words into a new word, and repeatedly concatenate that word n times. For example:

  • a would be uncompressed as a,
  • (a 3) would be uncompressed as aaa,
  • (a (b c d 2) 3) would be uncompressed as abcdbcdabcdbcdabcdbcd.

Write a program to uncompress a compressed word.

Input:

The input consists of one correctly formed compressed word of different lengths on a separate line. Every compressed word in the input is correct according to the rules specified above. Letters and numbers are separated from each other by one space character. Brackets and numbers or letters are separated from each other by at least one space character. One bracket is separated from another by one space character.

Output:

For each test case (each compressed word), write the uncompressed word should be displayed on a new line. There should be no spaces in the output.

 

Input 1:

a

Input 2:

( a 3 )

Input 2:

( a ( b c d 2 ) 3 )

Output 1:

a

Output 2:

aaa

Output 3:

abcdbcdabcdbcdabcdbcd


Added by:Arjun Krishnan
Date:2014-03-16
Time limit:3s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:ASM32-GCC MAWK BC C-CLANG C NCSHARP CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG COBOL COFFEE D-CLANG D-DMD DART ELIXIR FANTOM FORTH GOSU GRV JAVA JS-MONKEY JULIA KTLN NIM OBJC OBJC-CLANG OCT PHP PICO PROLOG PYTHON PYPY PYPY3 R RACKET RUST CHICKEN SQLITE SWIFT UNLAMBDA VB.NET

hide comments
2014-03-17 13:29:29 Bhavik
length of expression?? value of n??
what are the constraints??
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.