QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 128 MB مجموع النقاط: 100

#12681. Pentomino Puzzle

الإحصائيات

The Wisdom Beads game board consists of a triangular tray and 12 distinct pieces. The tray is shown in Figure 1.

Figure 1

The 12 pieces are divided into 3 categories based on the number of beads:

Category 1: Contains 3 beads, only 1 shape. Symbol A, shape:

Category 2: Contains 4 beads, 3 shapes. Symbol B, shape: Symbol C, shape: Symbol D, shape:

Category 3: Contains 5 beads, 8 shapes. Symbol E, shape: Symbol F, shape: Symbol G, shape: Symbol H, shape: Symbol I, shape: Symbol J, shape: Symbol K, shape: Symbol L, shape:

Figure 2 shows a completed board configuration. For easier description, Figure 2 can be abstracted into Figure 3, which can be represented by a two-dimensional array of characters.

Figure 2

B 
B K 
B K K 
B J K K 
J J J D D 
G J G D D C 
G G G C C C I 
E E E H H I I A 
E L H H H I A A F
E L L L L I F F F F

Figure 3

The pieces made of beads can be placed in any position on the board, provided there is space and the dimensions fit. All pieces are allowed to be rotated ($0^\circ, 90^\circ, 180^\circ, 270^\circ$) and flipped (horizontally or vertically).

Given an initial layout of the board, find a valid Wisdom Beads placement scheme such that all pieces are placed into the board.

Input

The input contains the description of the initial board layout, consisting of 10 lines, where the $i$-th line contains $i$ characters. If the $j$-th character of the $i$-th line is one of the letters "A" through "L", it indicates that a piece has already been placed at the $i$-th row and $j$-th column, with the piece identified by the corresponding letter. If the $j$-th character of the $i$-th line is ".", it indicates that the cell at the $i$-th row and $j$-th column is empty.

The input guarantees that the pre-placed pieces are already correctly positioned on the board.

Output

If a solution is found, print 10 lines representing the layout after all 12 pieces have been placed. The $i$-th line should contain $i$ characters, where the $j$-th character of the $i$-th line indicates which piece is placed at the $i$-th row and $j$-th column.

If no solution exists, output the single string No solution (without quotes, case-sensitive). All data is guaranteed to have at most one solution.

Examples

Input 1

.
..
...
....
.....
.....C
...CCC.
EEEHH...
E.HHH....
E.........

Output 1

B
BK
BKK
BJKK
JJJDD
GJGDDC
GGGCCCI
EEEHHIIA
ELHHHIAAF
ELLLLIFFFF

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.