Submit | All submissions | Best solutions | Back to list |
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":
- a single, lower-case letter is a compressed word
- (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-26 16:15:07 mce coders
I think problem is still solvable....but yes psetter should allow all languages good question though... |
|||||
2014-03-26 15:36:44 Bhavik
i am ok with francky's suggestion..let us wait for one week and then see what happens |
|||||
2014-03-26 12:26:24 Bhavik
though it truly deserves to be in classical,but due to the ignorance of psetter all the efforts of users trying to do this is wasted:( i think spoj administrators should take away problem making rights from such people who don't care to make right problems or if psetter have some time issues they should atleast say so that we can look for problem after some time again.. --ans(Francky)--> IMHO, if there's no response from psetter within a week, you (or another solver of this task) should freely make your own equivalent problem with full description and constraints that try to ovoid 0.00s solutions and in the same time allow slow languages solution. (This should be the rule for most of problems I think.) If there are candidate for such a task : make announcement here, and wait a week for psetter answer. Anyone can suggest a better option too. ;-) Last edit: 2014-03-26 13:26:15 |
|||||
2014-03-26 10:57:28 anurag garg
certainly not a tutorial stuff... --ans(Francky)--> Description is incomplete , all languages are not allowed. It will be back to classical and visible when the problem will be fully ready. We are waiting for psetter since a long time now. Last edit: 2014-03-26 11:20:17 |
|||||
2014-03-26 08:41:02 Bhavik
@skt: look out for REGULAR EXPRESSIONS..can't give you spoilers though |
|||||
2014-03-24 22:27:21 skt
@Bhavik: am getting WAs repeatedly but can't make out what's going wrong. Can I have a few test cases please for the edge cases? |
|||||
2014-03-24 14:08:27 anurag garg
easy to implement with c++ |
|||||
2014-03-23 11:43:52 Bhavik
any tricky cases?? finally ac :)) very strong testcases indeed!! i don't know if it is easy or difficult to do this question in C++(bcoz of string in c++) but in C ,it was difficult for me atleast:) or i made it difficult for myself! but very nice question:) Last edit: 2014-03-23 15:37:28 |
|||||
2014-03-17 13:29:29 Francky
Constraints have to be fully given. Please allow all language and make sure time allow to get AC. Hidden waiting for that. |
|||||
2014-03-17 13:29:29 newbie
@problem Setter: M getting wrong ans...can u point out if my approach is correct |