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

题意:你有一个炸弹,可以放在任意位置并炸掉该位置所在的行和列上的墙“*”,求一颗炸弹是否能炸掉所有的墙。

我们可以将每行和每列的墙数分别存入数组x[]和y[]。每当a[i][j]的位置是"*"时,x[i]++,y[j]++;最后再将x[i]+y[j]与总墙数sum比较。

注意:当炸弹所在点为“*”时,需x[i]+y[j]-1;

附AC代码:

 #include<iostream>
#include<cstring> using namespace std; int N,M,ans;
int a[][],x[],y[];
char s[]; void process(){
scanf("%d %d",&N,&M);
int cnt = ;
for(int i=; i<=N; i++){
scanf("%s",s);
for(int j=; j<=M; j++){
if(s[j-] == '*'){
x[i]++;
y[j]++;
cnt++;
a[i][j] = ;
}
}
}
for(int i=; i<=N; i++){
for(int j=; j<=M; j++){
int t;
t = x[i]+y[j];
if(a[i][j] == ) t--;//重复一个
if(t == cnt){
printf("YES\n%d %d\n",i,j);
return;
}
}
}
printf("NO\n");
} int main(){
process();
return ;
}

最新文章

  1. ABP框架 - 模块系统
  2. iOS中使用正则
  3. Hibernate 参数设置一览表
  4. ubuntu 双线双网卡双IP实现方式
  5. hdu 2177 取(2堆)石子游戏(威佐夫博奕)
  6. C++中,指针数组和数组指针
  7. SSD在SQLServer中的应用
  8. Unity多语言本地化改进版
  9. 使用PHP发送邮件
  10. ios import和@class的区别
  11. Searching a 2D Sorted Matrix Part I
  12. BZOJ3394: [Usaco2009 Jan]Best Spot 最佳牧场
  13. 在web网页中正确使用图片格式
  14. [daily] cscope
  15. Warning: count(): Parameter must be an array or an object that implements Countable in line 302解决方法
  16. 学会学习:高效学习方式(使用vscode-snippet有感)
  17. Python实现将爱词霸每日一句定时推送至微信
  18. 【mysql】 mysql忘记密码
  19. nmap 扫描信息收集
  20. c/c++保存日志程序模板

热门文章

  1. jsp表达式
  2. UVA11770 - Lighting Away
  3. nanoporetech/nanonet
  4. javascript点滴积累
  5. 如何清除本地DNS缓存 windows
  6. disabled和readonly
  7. HDU 1247 Hat’s Words(字典树变形)
  8. SQL还原数据库后,数据库显示受限制用户解决方法
  9. 2018.11.06 生成器函数进阶&amp;列表推导式&amp;生成器表达式
  10. Sparksql 取代 Hive?