No.3729 I Hate Hexagonal Tiling
Problem Statement
Regular hexagons are arranged as shown in the figure to form a triangular grid. There are $N$ rows in total, and for $1 \leq i \leq N$, the $i$-th row contains $i$ regular hexagons.
Is it possible to write a positive integer in every regular hexagon so that the following holds for any $3$ mutually distinct regular hexagons $A, B, C$?
- If $A$ and $B$, $B$ and $C$, and $C$ and $A$ each share an edge, then, letting $a, b, c$ be the positive integers written in $A, B, C$ respectively, the sum of some $2$ of $a, b, c$ equals the remaining $1$.
If such a way of writing exists, find one example that minimizes the sum of the positive integers written in the regular hexagons.
If no such way exists, output -1.
Constraints
- All inputs are integers.
- $2 \leq N \leq 500$
Input
The input is given from standard input in the following format.
$N$
Output
If a way of writing that satisfies the condition exists, output one example in the following format, where $H_{i, j}$ is the integer written in the regular hexagon in the $i$-th row and the $j$-th column from the left. If no way of writing satisfies the condition, output -1.
$H_{1, 1}$
$H_{2, 1}\ H_{2, 2}$
$H_{3, 1}\ H_{3, 2}\ H_{3, 3}$
$\vdots$
$H_{N, 1}\ H_{N, 2}\ \ldots\ H_{N, N}$
Print a newline at the end.
Visualizer
A web-based visualizer for the output is available here.
Sharing visualization results and discussing solutions or insights during the contest is prohibited. Please be careful.
In principle, questions about the visualizer's specifications will not be answered. Please use it only as an auxiliary tool.
Sample
Sample 1
Input
2
Output
2 1 1
$1 + 1 = 2$ holds. The sum of the written positive integers is $4$, which is the minimum.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。