Submit | All submissions | Best solutions | Back to list |
ONP - Transform the Expression |
Transform the algebraic expression with brackets into RPN form (Reverse Polish Notation). Two-argument operators: +, -, *, /, ^ (priority from the lowest to the highest), brackets ( ). Operands: only letters: a, b ... z. Assume that there is only one RPN form (no expressions like a*b*c).
Input
t [the number of expressions <= 100] expression [length <= 400] [other expressions]
Text grouped in [ ] does not appear in the input file.
Output
The expressions in RPN form, one per line.
Example
Input: 3 (a+(b*c)) ((a+b)*(z+x)) ((a+t)*((b+(a+c))^(c+d))) Output: abc*+ ab+zx+* at+bac++cd+^*
Added by: | mima |
Date: | 2004-05-01 |
Time limit: | 5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS PERL6 VB.NET |
Resource: | - |
hide comments
|
||||||||||||||
2016-01-13 11:47:36
Runs perfectly on ideone.com SIGSEGV here <snip> Last edit: 2023-02-09 23:13:58 |
||||||||||||||
2016-01-04 08:32:29
whooo hoo !! 2nd try ..// in the first try just an "endl" missing :P |
||||||||||||||
2015-12-31 10:41:16
I got RTE(NZec) I tried all known options to me , finally identified that I have not pushed "-" to stack . Pretty easy problem using stacks. My first one in stack . |
||||||||||||||
2015-12-27 15:51:29
@yeahboy this type is not allowed.. As it can have multiple rpn forms possible! |
||||||||||||||
2015-12-25 14:10:18 motasem mohammad
taught me how to use stack function , a good problem |
||||||||||||||
2015-12-17 18:36:07
Take care of the case a+b without any brackets ...caused me several wrong answers Last edit: 2015-12-28 11:04:45 |
||||||||||||||
2015-12-13 21:25:34 Timmy Jose
Nice question - excellent motivation to revise old college stuff! :-) |
||||||||||||||
2015-12-09 07:05:06 MAYANK NARULA
@ yeahboy ... My answer for that is abc*-w-lde-fg+*-h+ijk-*p/^- But i am getting WRONG ANSWERS in SPOJ...!! Now i got it AC ... Can't resist making output format mistakes !! Last edit: 2015-12-09 07:10:57 |
||||||||||||||
2015-10-21 14:25:15 Mayur Aggarwal
My code is giving correct answer on ideone but couldn't able to nail down the issue/bug for which SPOJ is giving wrong answer. few checks are given below please advise if any see any issue: All variables declared with array size 401, if(T<=100 && T >=1) //test condition if(strlen(str) <=400 && strlen(str) >=1) // input check logic seems to be correct.. As per SPOJ guidelines I can't post source code here. Please post more test cases here so that I can validate my code. Any help is appreciated. Thnaks!! |
||||||||||||||
2015-10-12 21:04:55 Michael
In my case it's: abc*wlde-fg+h+*-ijk-p/*^--- |