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+^*
hide comments
Abhyudaya Ranglani:
2015-02-21 15:38:45
I've been struggling like crazy to get rid of NZEC. I am almost certain that this code (http://ideone.com/********) deals appropriately with all possible statements that may throw exceptions. I think the memory constraint might be the issue here. Would appreciate any help.
|
|
Serene Brackets:
2015-02-18 04:55:45
It's good that you people know the answer, but don't give the hints here. Let people figure it out and have fun doing it. |
|
thelazycoder:
2015-02-13 18:17:40
learnt a new thing from this question .. good question |
|
Shubham Kaushik:
2015-02-10 17:01:28
<snip>
|
|
Indian Cyber Army (IndiShell):
2015-01-31 13:49:06
stack implementation |
|
Shabeeb Hashim:
2015-01-26 07:51:21
Fully parenthesized expression :),so no need to use infix to post fix conversion algorithm,it is simpler than that... |
|
Sachin verma:
2015-01-18 12:39:15
Well Rishab Both are differnet test case Last edit: 2015-01-18 12:40:12 |
|
Rishabh Agarwal:
2015-01-18 07:55:55
is this is a test case : (a + b^c)
|
|
Sachin verma:
2015-01-14 20:07:22
here +- got same priority and /* got same but higher than +-and( and ^ has highest priority
|
|
Vinshi Vanvat:
2015-01-08 07:14:32
operating successfully on ideone but segmentation fault coming on spoj.. please help !!!
|
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: | - |