#P14687. [ICPC 2025 Yokohama R] U-Shaped Panels
[ICPC 2025 Yokohama R] U-Shaped Panels
题目描述
A rectangular pond is in the backyard of your house. As the length and width of the pond are integer multiples of one meter, the pond can be considered to consist of one-meter-square sections.
You always feel the pond is too large, and you want to cover some of its sections using the panels kept in the barn. All of these panels have the same size and the same shape, consisting of one-meter-square boards arranged in a U shape. The overall size of the panels is meters by meters, and boards are on the three edges of that square. The rest, the rectangular area, is void. Figure H.1 illustrates a panel of size .
:::align{center}

Figure H.1. A panel of size (left) and its top view (right) :::
You plan to cover certain one-meter-square sections of the pond with the panels and leave the rest uncovered. Panels should be placed so that each of their boards fits exactly one section. As long as this is satisfied, orientations of the panels can be arbitrarily chosen. Panels should not overlap one another nor stick out of the pond.
Determine whether your plan is feasible or not.
输入格式
The input contains one or more test cases. The first line of the input contains an integer (), which is the number of test cases. The descriptions of the test cases follow, each in the following format.
The first line contains three integers , , and . The integers and denote the length and the width of the pond, respectively (, ). The integer denotes the size of the U-shaped panels (). The following lines represent your plan. The -th of them contains a string of length consisting of the characters '#' and '.'. Let us say a one-meter-square section is at if it lies between meters and meters from the front edge, and between meters and meters from the left edge. For each and , if the -th character of is '#', the section at should be fully covered with a board of a panel. Otherwise, the section should remain fully uncovered.
The sum of 's over all the test cases does not exceed 1000. The same applies to .
输出格式
For each test case, output in a line yes if your plan is feasible; no otherwise.
1
10 10 5
..........
..........
....#####.
..#.#.#.#.
..#.#.#.#.
..#.#.#.#.
..#.#.#.#.
..#####...
..........
..........
yes
2
5 21 5
.#...##...###....##..
.#..#..#..#..#..#..#.
.#..#.....###...#....
.#..#..#..#.....#..#.
.#...##...#......##..
6 14 6
.############.
.#..........#.
.#..........#.
.#..........#.
.#..........#.
.############.
no
yes