Codeforces Round 306 (Div. 2)
E
Brackets in Implications
Codeforces
2200
原题
← D→
翻译中…

Implication is a function of two logical arguments, its value is false if and only if the value of the first argument is true and the value of the second argument is false.

翻译中…

Implication is written by using character '', and the arguments and the result of the implication are written as '0' ($*false*$) and '1' ($*true*$). According to the definition of the implication:

翻译中…

image imageimage image

翻译中…

When a logical expression contains multiple implications, then when there are no brackets, it will be calculated from left to fight. For example,

翻译中…

image.

翻译中…

When there are brackets, we first calculate the expression in brackets. For example,

翻译中…

image.

翻译中…

For the given logical expression image determine if it is possible to place there brackets so that the value of a logical expression is false. If it is possible, your task is to find such an arrangement of brackets.

翻译中…

Input

翻译中…

The first line contains integer $*n*$ ($1 ≤ *n* ≤ 100 000$) — the number of arguments in a logical expression.

翻译中…

The second line contains $*n*$ numbers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ (image), which means the values of arguments in the expression in the order they occur.

翻译中…

Output

翻译中…

Print "NO" (without the quotes), if it is impossible to place brackets in the expression so that its value was equal to 0.

翻译中…

Otherwise, print "YES" in the first line and the logical expression with the required arrangement of brackets in the second line.

翻译中…

The expression should only contain characters '0', '1', '-' (character with ASCII code 45), '>' (character with ASCII code 62), '(' and ')'. Characters '-' and '>' can occur in an expression only paired like that: ("->") and represent implication. The total number of logical arguments (i.e. digits '0' and '1') in the expression must be equal to $*n*$. The order in which the digits follow in the expression from left to right must coincide with $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$.

翻译中…

The expression should be correct. More formally, a correct expression is determined as follows:

翻译中…
  • Expressions "$0$", "$1$" (without the quotes) are correct.
  • If $*v*_{1}$, $*v*_{2}$ are correct, then $*v*_{1}$->$*v*_{2}$ is a correct expression.
  • If $*v*$ is a correct expression, then $(*v*)$ is a correct expression.
翻译中…

The total number of characters in the resulting expression mustn't exceed $10^{6}$.

翻译中…

If there are multiple possible answers, you are allowed to print any of them.

翻译中…

样例

Input #1
4
0 1 1 0
Output #1
YES
(((0)->1)->(1->0))
InputCopy OutputCopy
Input #2
2
1 1
Output #2
NO
InputCopy OutputCopy
Input #3
1
0
Output #3
YES
0
InputCopy OutputCopy
题目信息
题号
550E
时间限制
2 s
内存限制
256 MB
标签
构造
贪心
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。