公式

C - Hamiltonian Pieces 解説 by evima


Necessary and Sufficient Conditions

Let \(N = R + B\). For each \(i\) \((1\leq i\leq N)\), denote by \((r_i,c_i)\) the square on which the \(i\)-th piece is placed. Also, let \((r_{N+1}, c_{N+1}) = (r_1, c_1)\). Then, if the \(i\)-th piece is red, the parity of \((r_i + c_i)\) and \((r_{i+1} + c_{i+1})\) differ; if the \(i\)-th piece is blue, these parities are the same. Since \((r_{N+1}, c_{N+1}) = (r_1, c_1)\), we get the following necessary condition:

  • \(R\) must be even.

Furthermore, if \(R = 0\), then the parity of \(r_i\) and \(r_{i+1}\) differ, so we get another necessary condition:

  • If \(R = 0\), then \(B\) must be even.

If these two conditions are satisfied, there does indeed exist a way to place the \(N\) pieces so that all conditions are met.

Construction

Below are examples of how to place the pieces satisfying the conditions for certain \((R,B)\). The same placement method can be applied to other \((R,B)\) pairs as well.

If \(R=0\)

Example: \((R,B) = (0,8)\)

...B.
..B.B
.B.B.
B.B..
.B...

If \(R\geq 1\) and \(B\) is odd

Example: \((R,B) = (8,5)\)

.....BR
....BB.
RRRRB..
RRRB...

If \(R\geq 1\) and \(B\) is even

Example: \((R,B) = (8,6)\)

......B
.....BR
....BB.
RRRRB..
RRRB...

投稿日時:
最終更新: