問題一覧 > 通常問題

No.3729 I Hate Hexagonal Tiling

レベル : / AI推定難易度 : 1400 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 67
作問者 : 👑 kencho / テスター : uruzunyaa 👑 p-adic
お気に入りにしたユーザー ProblemId : 13578 / 自分の提出
問題文最終更新日: 2026-11-02 04:27:08
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
グリッド構築24題 (順位表) の他の問題:

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