Toyota Programming Contest 2023 Spring Qual A(AtCoder Beginner Contest 288)
G
3^N Minesweeper
AtCoder
⌀ 2606
原题
← Ex→
翻译中…

Problem Statement

翻译中…

There is zero or one bomb at each of positions $0, 1, 2, \ldots, 3^N-1$. Let us say that positions $x$ and $y$ are neighboring each other if and only if the following condition is satisfied for every $i=1, \ldots, N$.

翻译中…
  • Let $x'$ and $y'$ be the $i$-th lowest digits of $x$ and $y$ in ternary representation, respectively. Then, $|x' - y'| \leq 1$.
翻译中…

It is known that there are exactly $A_i$ bombs in total at the positions neighboring position $i$. Print a placement of bombs consistent with this information.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 12$
  • There is a placement of bombs consistent with $A_0, A_1, \ldots, A_{3^N-1}$.
  • All values in the input are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
A_0 A_1 \ldots A_{3^N-1}

翻译中…

Output

翻译中…

Print $B_0, B_1, \ldots, B_{3^N-1}$ with spaces in between, where $B_i = 0$ if position $i$ has no bomb and $B_i = 1$ if position $i$ has a bomb.

翻译中…

样例

Input #1
1
0 1 1
Output #1
0 0 1
Position $0$ is neighboring positions $0$ and $1$, which have $0$ bombs in total. Position $1$ is neighboring positions $0$, $1$, and $2$, which have $1$ bomb in total. Position $2$ is neighboring positions $1$ and $2$, which have $1$ bombs in total. If there is a bomb at only position $2$, all conditions above are satisfied, so this placement is correct.
Input #2
2
2 3 2 4 5 3 3 4 2
Output #2
0 1 0 1 0 1 1 1 0
Input #3
2
0 0 0 0 0 0 0 0 0
Output #3
0 0 0 0 0 0 0 0 0
题目信息
题号
abc288_g
时间限制
2 s
内存限制
1024 MB

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