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).
t [the number of expressions <= 100] expression [length <= 400] [other expressions]
Text grouped in [ ] does not appear in the input file.
The expressions in RPN form, one per line.
Input: 3 (a+(b*c)) ((a+b)*(z+x)) ((a+t)*((b+(a+c))^(c+d))) Output: abc*+ ab+zx+* at+bac++cd+^*
Succeed.. But seems like i took long time.. almost 3 hours.. Is this a problem with me only? :-)
got ac in first attempt.....
hurrah, got AC in first Attempt.
feeling relaxed after doing this problem
For all those who are getting " SIGSEGV " error . Make change in your input. Try changing it to " string "data type or make your array size bigger
Runs perfectly on ideone.com
whooo hoo !! 2nd try ..// in the first try just an "endl" missing :P
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.
@yeahboy this type is not allowed.. As it can have multiple rpn forms possible!
taught me how to use stack function , a good problem
|Added by:||Michał Małafiejski|
|Cluster:||Cube (Intel G860)|
|Languages:||All except: NODEJS PERL 6 VB.net|