atcoder#ABC288G. [ABC288G] 3^N Minesweeper
[ABC288G] 3^N Minesweeper
Score : points
Problem Statement
There is zero or one bomb at each of positions . Let us say that positions and are neighboring each other if and only if the following condition is satisfied for every .
- Let and be the -th lowest digits of and in ternary representation, respectively. Then, .
It is known that there are exactly bombs in total at the positions neighboring position . Print a placement of bombs consistent with this information.
Constraints
- There is a placement of bombs consistent with .
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print with spaces in between, where if position has no bomb and if position has a bomb.
1
0 1 1
0 0 1
Position is neighboring positions and , which have bombs in total. Position is neighboring positions , , and , which have bomb in total. Position is neighboring positions and , which have bombs in total. If there is a bomb at only position , all conditions above are satisfied, so this placement is correct.
2
2 3 2 4 5 3 3 4 2
0 1 0 1 0 1 1 1 0
2
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0