D. Conditional Operators
constructive algorithms
In C++, the conditional operator ?: is used as the value of x?y:z is \(y\) if \(x\) is true; otherwise, the value is \(z\). \(x\), \(y\), and \(z\) may also be expressions. It is right-associated; that is, a?b:c?d:e is equivalent to a?b:(c?d:e). \(0\) means false and \(1\) means true.Given a binary string with length \(2n+1\), you need to show whether the value of the expression can be \(1\) after inserting \(n\) conditional operators into the string. You can use parentheses. For example, the string 10101 can be transformed into (1?0:1)?0:1, whose value is \(1\).
The first line contains a single integer \(t\) (\(1 \le t \le 10\,000)\), the number of test cases. The description of the test cases follows.In the first line of each test case, there is a single integer \(n\) (\(1 \le n \le 1.5 \cdot 10^5)\).In the second line of each test case, there is a binary string of length \(2n + 1\).It is guaranteed that the sum of \(n\) across all test cases does not exceed \(1.5 \cdot 10^5\).
For each test case, on the first line, output Yes if the string can be transformed into an expression of value \(1\); otherwise, output No.If the answer is Yes, output the expression on the second line. You can use parentheses, but the order of the characters in the original string must remain the same. The length of your expression must be no more than \(10n+1000\).
The first test case — is the one mentioned in the problem description.In the second test case, it is clear that regardless of how the conditional operator is used, the result will always be zero.