luogu#P1228. 地毯填补问题
地毯填补问题
Background
Description
It is said that in an ancient Arabian country, there was a palace. Inside the palace, there was a square grid maze. The king’s method for choosing a prince consort was very special and simple: the princess stood on one grid cell, and whoever could cover every other cell with carpets, except the one where the princess stood, would win the beautiful, elegant, and intelligent princess. The princess’s cell must not be covered, and the carpet shape is restricted to four options only (see the figure):

Each grid cell may be covered by at most one layer of carpet. The maze is a square of size . The time limit is second.
Output Format
Output a complete tiling plan: each placement (one line) is ( are the row and column of the carpet’s corner cell, and is the carpet’s shape; see Figure above. The four shapes are represented by . Separate with a single space).
3
3 3
5 5 1
2 2 4
1 1 4
1 4 3
4 1 2
4 4 1
2 7 3
1 5 4
1 8 3
3 6 3
4 8 1
7 2 2
5 1 4
6 3 2
8 1 2
8 4 1
7 7 1
6 6 1
5 8 3
8 5 2
8 8 1
Hint
Explanation of SPJ error codes:
- is out of range.
- are out of range.
- The position has already been covered.
- The position was never covered.
: Added sample explanation.
Sample Explanation

Translated by ChatGPT 5