No.1652 XOR Inequalities
Problem Statement
Rusk has a sequence $A=(A_0, A_1, \ldots, A_{2^N-1})$ of length $2^N$. Each element of $A$ is either $-1$ or an integer between $0$ and less than $2^{30}$. Rusk wants to replace every $-1$ contained in $A$ with an integer that is at least $0$ and less than $2^{30}$ so that the following condition is satisfied.
- For all $i$, $j$ ($0\leq i, j < 2^N$), $A_{i\oplus j}\geq A_i\oplus A_j$ holds.
Here, for non-negative integers $x$, $y$, $x\oplus y$ denotes the bitwise XOR of $x$ and $y$.
Input
$N$
$A_0\ A_1\ \ldots \ A_{2^N-1}$
- $1\leq N\leq 7$
- $-1\leq A_i < 2^{30}$
- All input values are integers.
Output
If no replacement satisfying the condition exists, print No. Otherwise, print Yes on line $1$, and on line $2$, print the elements of $A$ after a replacement satisfying the condition, separated by spaces. If there are multiple valid ways of replacing, you may print any of them.
Sample
Sample 1
Input
2 2 -1 -1 6
Output
Yes 2 7 3 6
For example, if $A_1=7$, $A_2=3$, then $A_{i\oplus j}\geq A_i\oplus A_j$ is satisfied for all $i$, $j$ ($0\leq i, j< 4$).
Sample 2
Input
3 -1 4 -1 5 9 2 6 5
Output
No
No matter how $A_0$ and $A_2$ are replaced, $A_5< A_1\oplus A_4$ holds, so the condition is not satisfied.
Sample 3
Input
3 3 -1 -1 7 -1 -1 -1 10
Output
Yes 3 22 18 7 15 26 30 10
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
chocorusk
ei1333333