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 <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <ext/rope>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define vi vector<int>
#define pii pair<int,int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
const int maxn=1e3+;
const int dis[][]={{,},{-,},{,-},{,}};
using namespace std;
using namespace __gnu_cxx;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p;p=p*p;q>>=;}return f;}
int n,m,cnt,r[maxn],c[maxn];
char a[maxn][maxn];
int main()
{
int i,j,k,t;
scanf("%d%d",&n,&m);
rep(i,,n-)scanf("%s",a[i]);
rep(i,,n-)rep(j,,m-)
if(a[i][j]=='*')r[i]++,c[j]++,cnt++;
rep(i,,n-)rep(j,,m-)
if(r[i]+c[j]-(a[i][j]=='*')==cnt)
return *printf("YES\n%d %d\n",i+,j+);
puts("NO");
//system ("pause");
return ;
}

最新文章

  1. AE+C# 版本更新问题 命名空间“ESRI”中不存在类型或命名空间名称“Arcgis”(是缺少程序集引用吗?)
  2. 石子归并问题(nyoj737)
  3. nodejs对静态文件目录的处理
  4. C# 在word文档中复制表格并粘帖到下一页中
  5. weka简介
  6. 好用的JS压缩工具—JSCompress
  7. Java入门以及Java中的常量与变量总结
  8. Android + Eclipse + PhoneGap 环境配置
  9. golang 关于 interface 的学习整理
  10. JS之clientX,clientY,screenX,screenY,offsetX,offsetY区别
  11. Velocity中为什么要使用{}来明确标识变量
  12. Python - 列表解析式
  13. 两种ps切图方法(图层/切片)
  14. RPM安装MYSQL5.7
  15. lua中实现倒计时
  16. Python中通过open()操作文件时的文件中文名乱码问题
  17. iOS学习笔记(3)— 屏幕旋转
  18. Spring MVC——搭建HelloWeb工程
  19. 轻量级网络 - PVANet & SuffleNet
  20. DevExpress相关控件中非字符数值居左显示

热门文章

  1. js 第一天
  2. hdu_1011_Starship Troopers(树形DP)
  3. Entity Framework技巧系列之九 - Tip 35 - 36
  4. 使用SpringSecurity3用户验证(异常信息,验证码)
  5. PAC全自动脚本代理
  6. requirejs 一个拆分js项目的类库
  7. PHP xdebug的安装
  8. json的引号之伤
  9. Inno Setup入门(十八)&mdash;&mdash;Inno Setup类参考(4)
  10. 1.1 mysql安装