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+^*
|Added by:||Michał Małafiejski|
|Cluster:||Cube (Intel Pentium G860 3GHz)|
|Languages:||All except: NODEJS PERL 6 SCM chicken VB.net|
STL made code shorter......Excellent problem for beginners.......
Can someone please tell whether it is possible for the SPOJ compiler to judge wrongly. Because my code worked fine on idone.com but it shows wrong answer here. P.S. My code is in C.
hint : stack is used for the implementation
yeah AC in one go after thinking the algorithm about 1 hour haha, anyway, nice problem :)
i used cin.getline() to read the input and got WA too many times......and then used cin>> and got AC.....also check that array size is atleast 400
anyone done this is #c
RPN is a little cryptic, isn't it? IMO there are many spoj problems giving more fun and less popular so why this question is so popular (rank 6)?
You will step up from amateur level after solving this
my code went well in ideone.but its not working in this spoj compiler .and i did it in c