Sphere Online Judge

SPOJ Problem Set (classical)

4. Transform the Expression

Problem code: ONP

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.




Added by:Micha≥ Ma≥afiejski
Time limit:5s
Source limit:50000B
Memory limit:256MB
Cluster: Pyramid (Intel Pentium III 733 MHz)
Languages:All except: NODEJS PERL 6

hide comments
2014-07-26 18:10:09 Mayank Ladia
running on my pc but in this giving error (SIGSEGV)
2014-07-11 11:51:59 Akash

Last edit: 2014-07-11 11:53:26
2014-06-17 20:26:49 zicowa
AC in first Go :D
2014-06-12 05:57:56 Kapil
It runs perfectly on my PC but when I submit it gives me runtime error(SIGSEGV)
2014-06-06 10:28:21 chin
just based on stacks...AC!!..:D
2014-06-02 18:19:12 Aditya
+- and */ should have same priority but here they are not same. got lot of wrong answers cos of this. TC.
2014-05-25 11:15:28 Ashish
I am getting correct answers in Ubuntu but when I run here it shows "wrong answer"....can I know which answer is not correct??
2014-05-14 10:16:30 Sherif Vettom
very very easy make a stack and it
2014-03-08 07:43:05 Shubham Aggarwal
it is infix to postfix
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.