#K7171. Patch Placement in Grid
Patch Placement in Grid
Patch Placement in Grid
In this problem, you are given a grid of size (R \times C) consisting of cells that are either empty (represented by '.') or blocked by an obstacle (represented by 'P'). You are also given a patch of size (pr \times pc). Your task is to determine if the patch can be placed somewhere in the grid such that all cells covered by the patch are empty. The patch must lie completely within the grid boundaries and must not cover any cell containing 'P'.
inputFormat
The first line contains an integer (T), the number of test cases. Each test case is described as follows:
- The first line contains two integers (R) and (C), the number of rows and columns in the grid.
- The next (R) lines each contain a string of length (C) consisting of characters '.' and 'P', representing the grid.
- The next line contains two integers (pr) and (pc), the number of rows and columns of the patch.
All input is provided via standard input (stdin).
outputFormat
For each test case, output a single line in the format "Case i: Yes" if the patch can be placed in the grid without overlapping any obstacles, or "Case i: No" otherwise. Here, (i) is the 1-indexed test case number. All output should be written to standard output (stdout).## sample
3
5 5
.....
.PPPP
.....
.....
.....
2 2
4 4
PPPP
PPPP
PPPP
PPPP
2 2
4 4
....
.P..
....
....
3 2
Case 1: Yes
Case 2: No
Case 3: Yes
</p>