Problem G
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.
![\includegraphics[width=0.6\textwidth ]{pentominoes}](/problems/geometricgridlock/file/statement/en/img-0001.png)
The goal of this puzzle is to divide a grid into regions of size $5$ (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 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\times w$, and your task is to create any valid arrangement of pentominoes.
Input
The input consists of:
-
One line with two integers $h$ and $w$ ($1 \le h,w \le 100$), the height and width of the grid.
Output
If there is no valid $h\times w$ Pentominous grid, output “no”. Otherwise, output “yes”, followed by $h$ lines of width $w$ each, a possible grid using the letters from Figure 1. If there is more than one solution, any one of them will be accepted.
Note
![\includegraphics[scale=0.15]{01.png}](/problems/geometricgridlock/file/statement/en/img-0002.png)
![\includegraphics[scale=0.15]{02.png}](/problems/geometricgridlock/file/statement/en/img-0003.png)
![\includegraphics[scale=0.15]{03.png}](/problems/geometricgridlock/file/statement/en/img-0004.png)
Sample Input 1 | Sample Output 1 |
---|---|
3 5 |
yes UUXUU UXXXU UUXUU |
Sample Input 2 | Sample Output 2 |
---|---|
2 10 |
yes LLLLNNNPPP LIIIIINNPP |
Sample Input 3 | Sample Output 3 |
---|---|
99 17 |
no |
Sample Input 4 | Sample Output 4 |
---|---|
6 10 |
yes IPPYYYYVVV IPPXYLLLLV IPXXXFZZLV ITWXFFFZUU ITWWNNFZZU TTTWWNNNUU |
Sample Input 5 | Sample Output 5 |
---|---|
1 5 |
yes IIIII |