問題一覧 > 通常問題

No.1652 XOR Inequalities

レベル : / AI推定難易度 : 2850 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 10
作問者 : chocorusk / テスター : ei1333333
お気に入りにしたユーザー ProblemId : 6697 / 自分の提出
問題文最終更新日: 2021-08-21 00:38:43
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 310 (順位表) の他の問題:

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.
Determine whether this is possible, and if it is possible, find $1$ way of replacing that satisfies the condition.

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もしくは右上の雲マークをクリックしてアカウントを作成してください。