All submissions for this problem are available.Algebra and coders share the same love as of Professor and Raquel of Money Heist, as we like solving mathematical problems. We always come across some really complex expressions faced as hostages and there are always some unneeded parentheses of Madrid police inside the expression. Your task is to take these partial results and make them "nice" by removing all unnecessary parentheses and perform a successful heist of Royal Mint of Spain. ###Input: TestCases(No. of expressions) T. T expressions follow. Each expression consists of a single line containing only lowercase letters, operators (+, -, *, /) and parentheses (( and )). Operators have their usual priority. All operations with the same priority are computed from left to right (operators are left-associative). There are no spaces inside the expressions. ###Output: Remove the unneeded parentheses and print each expression in a separate line. The expression obeys additive and multiplicative associativity. You cannot use any other laws, namely you cannot swap left and right operands and you cannot replace "a-(b-c)" with "a-b+c". ###Constraints : 1≤T≤10000 No input line contains more than 250 characters ###Sample Input : 8 (a+(b*c)) ((a+b)*c) (a*(b*c)) (a*(b/c)*d) ((a/(b/c))/d) ((x)) (a+b)-(c-d)-(e/f) (a+b)+(c-d)-(e+f) ###Sample Output : a+b*c (a+b)*c a*b*c a*b/c*d a/(b/c)/d x a+b-(c-d)-e/f a+b+c-d-(e+f)
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.