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<stdio.h>
#include<iostream>
#include<map>
using namespace std;
char ma[][];
int main(){
int n,m;
int x=-;
int y=-;
int hang[];
int lie[];
int cnt=;
scanf("%d%d",&m,&n);
for(int i=;i<m;i++) hang[i]=;
for(int j=;j<n;j++) lie[j]=;
for(int i=;i<m;i++){
scanf("%s",ma[i]);
}
for(int i=;i<m;i++){
for(int j=;j<n;j++){
if(ma[i][j]=='*'){
hang[i]++;
lie[j]++;
cnt++;
}
} }
for(int i=;i<m;i++){
for(int j=;j<n;j++){
int tmp=hang[i]+lie[j];
if(ma[i][j]=='*') tmp--;
if(tmp==cnt){
printf("YES\n%d %d",i+,j+);
return ;
}
}
}
printf("NO\n");
return ;
}

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

最新文章

  1. SIP学习笔记(转)
  2. java Proxy(代理机制)
  3. WingIDE中文乱码问题解决方法
  4. php的&lt;?php ?&gt;标签匹配
  5. windows完全支持C++11的轻量级编译器(官网MinGW和非官方的MinGW-builds)
  6. MAC中使用Vim和GCC编译C程序
  7. python多线程场景下print丢失
  8. jQuery each和js forEach用法比较
  9. PHP原生写的生成图片缩略图类
  10. c# 将object尝试转为指定对象
  11. linux下umask的使用讲解
  12. python发送网络请求
  13. 详解基于朴素贝叶斯的情感分析及 Python 实现
  14. luogu P1486 [NOI2004]郁闷的出纳员
  15. 003_vim使用tip
  16. c++ 多继承 公有,私有,保护
  17. 20172308 实验三《Java面向对象程序设计 》实验报告
  18. C++ Primer 5th 第19章 特殊工具与技术
  19. poj 3348:Cows(计算几何,求凸包面积)
  20. How to Get the Length of File in C

热门文章

  1. &lt;摘录&gt;字节对齐(强制对齐以及自然对齐)
  2. JS面向对象之作用域
  3. 【mybatis】mybatis中insert 主键自增和不自增的插入情况【mysql】
  4. Swift,数组
  5. [Git] git merge和rebase的区别
  6. 【日志处理、监控ELK、Kafka、Flume等相关资料】
  7. 二分求幂 - A^B(王道*)
  8. virtualbox虚拟机ubuntu操作系统,设置网络互通、访问,能访问虚拟机swoole的http服务
  9. 倍福TwinCAT(贝福Beckhoff)应用教程12.3 TwinCAT控制松下伺服 NC进阶
  10. 依据错误原理解决Hibernate执行出现No CurrentSessionContext configured!错误