#P5935. [清华集训 2012] 攻占黄金乡
[清华集训 2012] 攻占黄金乡
Background
The Chinese translation of Umineko no Naku Koro ni EP8 was finally released at the end of this summer vacation. As Furudo Erika, a very popular character in the whole work, she was naturally very active in the story. She served as the commander in the battle to conquer the Golden Land, and the entire battle process was recorded in the City of Books, making it convenient for later people to review it.
Problem Description
The battle situation at that time was as follows. The Golden Land can be viewed as a cuboid space. We use to represent each unit cell inside it. Erika commanded warships of different ranks to suddenly appear in different cells of the Golden Land using magic. After that, goats continuously poured out from the warships. In each unit of time, the goats will expand from their current cell to the adjacent cells in the directions by one cell (if the neighboring cell has already been occupied, they do not expand into it). If two groups of goats want to occupy the same cell at the same time, the higher-rank goats occupy it first.
Soon, the Golden Land turned into an ocean of goats. But Erika, as the commander, could not find the locations of the warships among the huge number of goats. So she handed the problem to you, Mr. Goat, who was a young general eager to gain military merit and then return to his hometown to find Goat Girl. Naturally, you would not give up this opportunity, so you quickly found the warships’ locations. Your achievement would of course be recorded in the documents of the City of Books.
Input Format
The first line contains an integer , the number of test cases. The following are test cases.
For each test case, the first line contains three integers . Then there are blocks, each block consists of an -row -column character matrix.
The -th block describes the situation in the region .
Goats of different ranks are represented by different lowercase English letters. A letter with a smaller lexicographical order means a higher goat rank.
Adjacent blocks are separated by a blank line.
Output Format
Output parts, separated by a blank line.
For each part, output lines, where is the number of warships in this test case. Each line has the format
ch x y z
meaning that the warship with label is located at .
The output order of warships does not matter. If there are multiple solutions, output any one.
2
1 2 2
dd
gg
3 3 3
aaa
aaa
baa
aaa
aaa
baa
aaa
aaa
bcc
d 0 0 0
g 0 1 0
a 1 1 1
b 1 2 0
c 2 2 1
Hint
Data Scale and Constraints
Test points : , .
Test points : , .
Test points : , .
Test points : .
For all testdata, , .
Translated by ChatGPT 5