#P13722. [GCPC 2024] Geometric Gridlock

[GCPC 2024] Geometric Gridlock

题目描述

Pentominous is a grid logic puzzle based on the twelve pentominoes. A pentomino is a polygon formed by connecting five equal-sized squares edge to edge.

:::align{center}

Figure G.1: The twelve pentominoes (up to mirroring and rotations) and their names. :::

The goal of this puzzle is to divide a grid into regions of size 55 (that is, pentominoes), so that no two regions that share a side have the same shape. You are allowed to rotate and mirror the pentominoes, but such rotations and reflections count as the same shape. The twelve possible shapes can be seen in Figure G.1.

In a normal Pentominous puzzle, the player is given some pre-filled cells, for which the shape of their region is already predetermined. In this problem, you are working with a completely blank grid of dimensions h×wh\times w, and your task is to create any valid arrangement of pentominoes.

输入格式

The input consists of:

  • One line with two integers hh and ww (1h,w1001 \le h,w \le 100), the height and width of the grid.

输出格式

If there is no valid h×wh\times w Pentominous grid, output "no\texttt{no}". Otherwise, output "yes\texttt{yes}", followed by hh lines of width ww each, a possible grid using the letters from Figure G.1. If there is more than one solution, any one of them will be accepted.

3 5
yes
UUXUU
UXXXU
UUXUU
2 10
yes
LLLLNNNPPP
LIIIIINNPP
99 17
no
6 10
yes
IPPYYYYVVV
IPPXYLLLLV
IPXXXFZZLV
ITWXFFFZUU
ITWWNNFZZU
TTTWWNNNUU
1 5
yes
IIIII

提示

:::align{center}

Illustration of Sample Output 1. Illustration of Sample Output 2. Illustration of Sample Output 4.

Example Pentominous puzzles for you to try after the contest.

:::