#abc312b. B - TaK Code
B - TaK Code
Score : points
问题描述
高桥发明了一种二维码——Takahashi 码(简称 TaK Code)。一个 TaK Code 满足以下所有条件:
- 它由九行横排和九列竖排构成的区域。
- 左上角和右下角的三行三列区域内共 个单元格都是黑色的。
- 与左上角或右下角三行三列区域相邻(水平、垂直或对角线方向)的全部 个单元格为白色。
不允许旋转 TaK Code。
现在给定一个包含 行和 列的网格。网格的状态通过 个长度为 的字符串 描述,其中第 行从上到下、第 列从左到右的单元格如果在 中的第 个字符是 #
,则表示该单元格为黑色;如果是.
,则表示为白色。
找出网格内所有满足 TaK Code 条件的九行九列完全包含在内的区域。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi invented Tak Code, a two-dimensional code. A TaK Code satisfies all of the following conditions:
- It is a region consisting of nine horizontal rows and nine vertical columns.
- All the cells in the top-left and bottom-right three-by-three regions are black.
- All the cells that are adjacent (horizontally, vertically, or diagonally) to the top-left or bottom-right three-by-three region are white.
It is not allowed to rotate a TaK Code.
You are given a grid with horizontal rows and vertical columns. The state of the grid is described by strings, , and , each of length . The cell at the -th row from the top and -th column from the left is black if the -th character of is #
, and white if it is .
.
Find all the nine-by-nine regions, completely contained in the grid, that satisfy the conditions of a TaK Code.
Constraints
- and are integers.
- is a string of length consisting of
.
and#
.
Input
The input is given from Standard Input in the following format:
Output
For all pairs such that the nine-by-nine region, whose top-left cell is at the -th row from the top and -th columns from the left, satisfies the conditions of a TaK Code, print a line containing , a space, and in this order.
The pairs must be sorted in lexicographical ascending order; that is, must be in ascending order, and within the same , must be in ascending order.
Sample Input 1
19 18
###......###......
###......###......
###..#...###..#...
..............#...
..................
..................
......###......###
......###......###
......###......###
.###..............
.###......##......
.###..............
............###...
...##.......###...
...##.......###...
.......###........
.......###........
.......###........
........#.........
Sample Output 1
1 1
1 10
7 7
10 2
A TaK Code looks like the following, where #
is a black cell, .
is a white cell, and ?
can be either black or white.
###.?????
###.?????
###.?????
....?????
?????????
?????....
?????.###
?????.###
?????.###
In the grid given by the input, the nine-by-nine region, whose top-left cell is at the -th row from the top and -nd column from the left, satisfies the conditions of a TaK Code, as shown below.
###......
###......
###......
.........
..##.....
..##.....
......###
......###
......###
Sample Input 2
9 21
###.#...........#.###
###.#...........#.###
###.#...........#.###
....#...........#....
#########...#########
....#...........#....
....#.###...###.#....
....#.###...###.#....
....#.###...###.#....
Sample Output 2
1 1
Sample Input 3
18 18
######............
######............
######............
######............
######............
######............
..................
..................
..................
..................
..................
..................
............######
............######
............######
............######
............######
............######
Sample Output 3
There may be no region that satisfies the conditions of TaK Code.
update @ 2024/3/10 08:53:05