首页 > cf #363 b

cf #363 b

B. One Bomb
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

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.

Output

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.

Examples
input
3 4

.*..

....

.*..
output
YES

1 2
input
3 3

..*

.*.

*..
output
NO
input
6 5

..*..

..*..

*****

..*..

..*..

..*..
output
YES

3 3







#include
#include
#include
using namespace std;
char ma[1005][1005];
int main(){int n,m;int x=-1;int y=-1;int hang[1005];int lie[1005];int cnt=0;scanf("%d%d",&m,&n);for(int i=0;i0;for(int j=0;j0;for(int i=0;i){scanf("%s",ma[i]);}for(int i=0;i){for(int j=0;j){if(ma[i][j]=='*'){hang[i]++;lie[j]++;cnt++;}}}for(int i=0;i){for(int j=0;j){int tmp=hang[i]+lie[j];if(ma[i][j]=='*') tmp--;if(tmp==cnt){printf("YES
%d %d",i+1,j+1);return 0;}}}printf("NO
");return 0;
}
View Code

分别统计行和列中到墙的个数,如果某个 行和列中包含全部到墙,则为答案。

转载于:https://www.cnblogs.com/superxuezhazha/p/5690607.html

更多相关:

  • 上篇笔记中梳理了一把 resolver 和 balancer,这里顺着前面的流程走一遍入口的 ClientConn 对象。ClientConn// ClientConn represents a virtual connection to a conceptual endpoint, to // perform RPCs. // //...

  • 我的实验是基于PSPNet模型实现二维图像的语义分割,下面的代码直接从得到的h5文件开始往下做。。。 也不知道是自己的检索能力出现了问题还是咋回事,搜遍全网都没有可以直接拿来用的语义分割代码,东拼西凑,算是搞成功了。 实验平台:Windows、VS2015、Tensorflow1.8 api、Python3.6 具体的流程为:...

  • Path Tracing 懒得翻译了,相信搞图形学的人都能看得懂,2333 Path Tracing is a rendering algorithm similar to ray tracing in which rays are cast from a virtual camera and traced through a s...

  • configure_file( [COPYONLY] [ESCAPE_QUOTES] [@ONLY][NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ]) 我遇到的是 configure_file(config/config.in ${CMAKE_SOURCE_DIR}/...

  •     直接复制以下代码创建一个名为settings.xml的文件,放到C:UsersAdministrator.m2下即可  http...

  • 首先运行easy_install pymongo命令安装pymongo驱动。然后执行操作: 创建连接 1 In [1]: import pymongo 2 3 In [2]: connection = pymongo.Connection('localhost', 27017) 切换到数据库malware In [3]: db...

  • 代码: public class Person{public int ID { get; set; }public string Name { get; set; }public int Age { get; set; } }public class Dog{public int ID { get; set; }...