CF699B.One Bomb
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell in a field can be empty (".") or it can be occupied by a wall ("*").
You have one bomb. If you lay the bomb at the cell (x, y), then after triggering it will wipe out all walls in the row x and all walls in the column y.
You are to determine if it is possible to wipe out all walls in the depot by placing and triggering exactly one bomb. The bomb can be laid both in an empty cell or in a cell occupied by a wall.
给你一个仓库的描述。它是一个大小为 n×m 的矩形网格场地。场地中的每个格子要么为空(用 . 表示),要么被一堵墙占据(用 * 表示)。
你拥有一枚炸弹。若将炸弹放置在格子 (x,y) 处并引爆,则该炸弹会清除第 x 行中的所有墙以及第 y 列中的所有墙。
你需要判断:是否可以通过恰好放置并引爆一枚炸弹,清除仓库中所有的墙?炸弹可以放置在空格子中,也可以放置在有墙的格子上。
输入格式
The first line contains two positive integers n and m (1 ≤ n, m ≤ 1000) — the number of rows and columns in the depot field.
The next n lines contain m symbols "." and "*" each — the description of the field. j-th symbol in i-th of them stands for cell (i, j). If the symbol is equal to ".", then the corresponding cell is empty, otherwise it equals "*" and the corresponding cell is occupied by a wall.
第一行包含两个正整数 n 和 m(1 ≤ n, m ≤ 1000)—— 分别表示仓库场地的行数和列数。
接下来的 n 行,每行包含 m 个字符,每个字符为 “.” 或 “*” —— 描述该场地。其中第 i 行的第 j 个字符表示单元格 (i, j)。若该字符为 “.”,则对应单元格为空;否则为 “*”,表示该单元格被一堵墙占据。
输出格式
If it is impossible to wipe out all walls by placing and triggering exactly one bomb, then print "NO" in the first line (without quotes).
Otherwise print "YES" (without quotes) in the first line and two integers in the second line — the coordinates of the cell at which the bomb should be laid. If there are multiple answers, print any of them.
如果无法通过恰好放置并引爆一颗炸弹来清除所有墙壁,则在第一行输出 "NO"(不带引号)。
否则,在第一行输出 "YES"(不带引号),并在第二行输出两个整数——炸弹应放置的格子的坐标。如果有多个答案,输出任意一个即可。
输入输出样例
输入#1
3 4 .*.. .... .*..
输出#1
YES 1 2
输入#2
3 3 ..* .*. *..
输出#2
NO
输入#3
6 5 ..*.. ..*.. ***** ..*.. ..*.. ..*..
输出#3
YES 3 3
输入解题思路,AI测评打分。不知道怎么写?