#P5935. [清华集训 2012] 攻占黄金乡

    ID: 6696 远端评测题 5000ms 500MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>搜索2012Special Judge枚举剪枝CTT(清华集训/北大集训)

[清华集训 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 (0,0,0)(n1,m1,k1)(0,0,0)\sim(n-1,m-1,k-1) to represent each unit cell inside it. Erika commanded tt warships of different ranks to suddenly appear in tt 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 66 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 testtest, the number of test cases. The following are testtest test cases.

For each test case, the first line contains three integers n,m,kn,m,k. Then there are nn blocks, each block consists of an mm-row kk-column character matrix.

The ii-th block describes the situation in the region (i,0,0)(i,m1,k1)(i,0,0)\sim(i,m-1,k-1).

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 testtest parts, separated by a blank line.

For each part, output tt lines, where tt is the number of warships in this test case. Each line has the format

ch x y z

meaning that the warship with label chch is located at (x,y,z)(x,y,z).

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 131\sim3: n=1n=1, n×m×k10n\times m\times k\leqslant10.

Test points 464\sim6: n=1n=1, n×m×k100n\times m\times k\leqslant100.

Test points 7107\sim10: n=1n=1, n×m×k500n\times m\times k\leqslant500.

Test points 112011\sim20: n×m×k1500n\times m\times k\leqslant1500.

For all testdata, test10test\leqslant10, t26t\leqslant26.

Translated by ChatGPT 5