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+^*
AC in one go! :) Used trees though not very fast...
I wrote the code in c++, and for fast input/output, i often use
my code is running correctly for given test cases but on submitting showing wrong ans. any particular test case for which I should check.
Last edit: 2018-06-29 15:08:46
Last edit: 2018-06-08 00:53:12
my code got AC for the test case a+b-c whose output is abc-+ , but i think the output should be ab+c- , which one is correct ?
this is bery easy
0.00 sec in ASM
Solved without stack data structure !!!
You can try the Shunting Yard approach, or even go for RD parsing using a LL(k) grammar.
|Cluster:||Cube (Intel G860)|
|Languages:||All except: NODEJS PERL6 VB.NET|