103052: [Atcoder]ABC305 C - Snuke the Cookie Picker

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:7 Solved:0

Description

Score : $300$ points

Problem Statement

There is a grid with $H$ rows and $W$ columns. Let $(i, j)$ denote the square at the $i$-th row from the top and the $j$-th column from the left.
Initially, there was one cookie on each square inside a rectangle whose height and width were at least $2$ squares long, and no cookie on the other squares.
Formally, there was exactly one quadruple of integers $(a,b,c,d)$ that satisfied all of the following conditions.

  • $1 \leq a \lt b \leq H$
  • $1 \leq c \lt d \leq W$
  • There was one cookie on each square $(i, j)$ such that $a \leq i \leq b, c \leq j \leq d$, and no cookie on the other squares.

However, Snuke took and ate one of the cookies on the grid.
The square that contained that cookie is now empty.

As the input, you are given the state of the grid after Snuke ate the cookie.
The state of the square $(i, j)$ is given as the character $S_{i,j}$, where # means a square with a cookie, and . means a square without one.
Find the square that contained the cookie eaten by Snuke. (The answer is uniquely determined.)

Constraints

  • $2 \leq H, W \leq 500$
  • $S_{i,j}$ is # or ..

Input

The input is given from Standard Input in the following format:

$H$ $W$
$S_{1,1}$$S_{1,2}$$\dots$$S_{1,W}$
$S_{2,1}$$S_{2,2}$$\dots$$S_{2,W}$
$\vdots$
$S_{H,1}$$S_{H,2}$$\dots$$S_{H,W}$

Output

Let $(i, j)$ the square contained the cookie eaten by Snuke. Print $i$ and $j$ in this order, separated by a space.


Sample Input 1

5 6
......
..#.#.
..###.
..###.
......

Sample Output 1

2 4

Initially, cookies were on the squares inside the rectangle with $(2, 3)$ as the top-left corner and $(4, 5)$ as the bottom-right corner, and Snuke ate the cookie on $(2, 4)$. Thus, you should print $(2, 4)$.


Sample Input 2

3 2
#.
##
##

Sample Output 2

1 2

Initially, cookies were placed on the squares inside the rectangle with $(1, 1)$ as the top-left corner and $(3, 2)$ as the bottom-right corner, and Snuke ate the cookie at $(1, 2)$.


Sample Input 3

6 6
..####
..##.#
..####
..####
..####
......

Sample Output 3

2 5

Input

题意翻译

有一个 $H$ 行 $W$ 列的网格图。 网格图上存在一个唯一的矩阵,其边长都不小于 $2$,这个矩阵中的每个网格上都有一块曲奇(记为 `#`),而这个矩阵之外的所有格子上都没有曲奇(记为 `.`)。 现在,Snuke 吃掉了其中的一块曲奇,给出吃掉曲奇以后的网格图状态,你需要给出被吃掉的曲奇的位置。行坐标从上到下计算,列坐标从左到右计算,坐标从 $1$ 开始。 - $2\leq H,W\leq500$ - 网格图中的每个字符都是 `#` 或 `.`

Output

分数:300分

问题描述

有一个有$H$行和$W$列的网格。 让$(i, j)$表示从上数第$i$行、从左数第$j$列的方格。

最初,一个矩形内的每个方格都有一块饼干,矩形的 高度和宽度至少为2个方格,其他方格没有饼干。

正式地说,存在一个四元组整数$(a,b,c,d)$满足以下所有条件。

  • $1 \leq a \lt b \leq H$
  • $1 \leq c \lt d \leq W$
  • 每个方格$(i, j)$有一个饼干,满足$a \leq i \leq b, c \leq j \leq d$,其他方格没有饼干。

然而,Snuke从网格上拿起并吃掉了一块饼干。

包含那块饼干的方格现在是空的。

作为输入,您将获得Snuke吃掉饼干后网格的状态。

方格$(i, j)$的状态表示为字符$S_{i,j}$,其中#表示有饼干的方格,.表示没有饼干的方格。

找到被Snuke吃掉的饼干所在的方格。(答案是唯一确定的。)

约束

  • $2 \leq H, W \leq 500$
  • $S_{i,j}$是#.

输入

输入按照以下格式从标准输入给出:

$H$ $W$
$S_{1,1}$$S_{1,2}$$\dots$$S_{1,W}$
$S_{2,1}$$S_{2,2}$$\dots$$S_{2,W}$
$\vdots$
$S_{H,1}$$S_{H,2}$$\dots$$S_{H,W}$

输出

让$(i, j)$表示被Snuke吃掉的饼干所在的方格。在空格分隔的情况下打印$i$和$j$。


样例输入1

5 6
......
..#.#.
..###.
..###.
......

样例输出1

2 4

最初,饼干在矩形内,矩形的左上角为$(2, 3)$,右下角为$(4, 5)$,Snuke吃掉了$(2, 4)$的饼干。 因此,你应该打印$(2, 4)$。


样例输入2

3 2
#.
##

HINT

有一块矩形的饼干,其中一小块被吃了,被吃掉的坐标是什么?

加入题单

算法标签: