D - Break the Rules
All submissions for this problem are available.Chef is playing with an expression which consists of integer operands and the following binary **Bitwise** operators - **AND, OR** and **XOR**. He is trying to figure out that what could be the **Maximum** possible answer of the expression, given that he **can perform the operation in any order i.e not necessarily follow the rule of Precedence of operators** while evaluating the expression. After some time of consistent work Chef starts feeling exhausted and wants you to automate this process for him. Can you help him out? The expression has Bitwise operators in symbol format: - **&** stands for AND - **|** stands for OR - **^** stands for XOR **NOTE :** *It is guaranteed that the expression will always be valid, also each OPERATOR will always be preceded and succeeded by an OPERAND.* ###Input: - The first line of input contains a single integer $T$ denoting the number of test cases. - The only line of input for each test case is a $string$ which is the Chef's expression to evaluate. ###Output: For each test case print a single integer i.e the maximum possible value of Chef's expression. ###Constraints - $1 \leq T \leq 100$. - The number of **OPERATORS** in the expression will be **atleast 1** and **atmost 10**. - Each **OPERAND** may range from **0 to $10^9$**. ###Subtasks - *10 points* : The number of **OPERATORS** in the expression will be **atmost 5**. - *20 points* : The number of **OPERATORS** in the expression will be **atmost 8**. - *70 points* : Original constraints. ###Sample Input: 2 3^40|10^2 92^95|56&2&3 ###Sample Output: 43 95 ###EXPLANATION: #####CASE 2 : - If we first compute **(56 & 2)**, the expression becomes **92^95|0&3**, since **(56 & 2)** yields $0$. - Now on computing **(95 | 0)**, the expression becomes **92^95&3**. - Further on computing **(95 & 3)**, the expression becomes **92^3**. - Finally **(92 ^ 3)** yields **95**, which is the maximum value of the expression.
|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.