#P15778. [JAG 2025 Summer Camp #3] Spray on Surface
[JAG 2025 Summer Camp #3] Spray on Surface
题目描述
Consider an region with opposite corners at and .
Within this region, an object is built from blocks. Each block occupies exactly the unit cube for some integers . It is guaranteed that this object is connected and that it contains no cavities (i.e., every empty cell is connected to the exterior of the region).
You want to know the amount of spray paint required to paint the surface of this object. Compute the surface area of the object.
输入格式
The input consists of multiple test cases.
The first line contains an integer (), representing the number of test cases.
test cases follow. Each test case is given in the following format.
$$\begin{aligned} & N \\ & S_{1,1} \\ & S_{1,2} \\ & \vdots \\ & S_{1,N} \\ & S_{2,1} \\ & \vdots \\ & S_{N-1,N} \\ & S_{N,1} \\ & \vdots \\ & S_{N,N} \end{aligned} $$For each test case, the first line contains an integer (), representing the side length of the region containing the object.
The following lines each contain a string of length , representing the shape of the object. If the -th character of is ‘#’, then there is a block in the region . If it is ‘.’, there is no block in that region. The object satisfies the conditions in the problem statement.
输出格式
For the test cases, output the answers on separate lines. For each test case, output the surface area of the object on a single line.
2
2
##
#.
#.
..
3
###
#.#
###
###
#.#
###
###
#.#
###
18
64