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 ;
}

B. One Bomb (#363 Div.2)的更多相关文章

  1. Codeforces Round 363 Div. 1 (A,B,C,D,E,F)

    Codeforces Round 363 Div. 1 题目链接:## 点击打开链接 A. Vacations (1s, 256MB) 题目大意:给定连续 \(n\) 天,每天为如下四种状态之一: 不 ...

  2. Codeforces Round #363 (Div. 2) One Bomb

    One Bomb 题意: 只有一个炸弹,并且一个只能炸一行和一列的'*',问最后能否炸完所以'*',如果可以输出炸弹坐标 题解: 这题做的时候真的没什么好想法,明知道b题应该不难,但只会瞎写,最后越写 ...

  3. Codeforces Round #363 (Div. 2)->B. One Bomb

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

  4. Codeforces Round #363 (Div. 2) B. One Bomb (水题)

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

  5. Codeforces Round #363 (Div. 2) B. One Bomb —— 技巧

    题目链接:http://codeforces.com/contest/699/problem/B 题解: 首先统计每行每列出现'*'的次数,以及'*'出现的总次数,得到r[n]和c[m]数组,以及su ...

  6. Codeforces Round #363 Div.2[111110]

    好久没做手生了,不然前四道都是能A的,当然,正常发挥也是菜. A:Launch of Collider 题意:20万个点排在一条直线上,其坐标均为偶数.从某一时刻开始向左或向右运动,速度为每秒1个单位 ...

  7. Codeforces Round #363 (Div. 2) A、B、C

    A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  8. Codeforces Round #363 (Div. 2) B

    Description You are given a description of a depot. It is a rectangular checkered field of n × m siz ...

  9. Codeforces Round #363 (Div. 2) B 暴力

    Description You are given a description of a depot. It is a rectangular checkered field of n × m siz ...

随机推荐

  1. bash的几个特殊参数和位置参量

    http://blog.csdn.net/jiankun_wang/article/details/4336285 一.$*和$@ 首先介绍两个极其相似.很难区分的特殊参数$*和$@,先看如下输出: ...

  2. Linux 下编译安装OpenCV(zhuanzai)

    http://www.cnblogs.com/emouse/archive/2013/02/22/2922940.html Cmake的安装 OpenCV 2.2以后版本需要使用Cmake生成make ...

  3. iOS开发 - UIViewController控制器管理

    创建一个控制器 控制器常见的创建方式有下面几种 //通过storyboard创建 //直接创建 ViewController *vc = [[ViewController alloc] init]; ...

  4. Linux 系统监控.诊断工具之 IO wait

    1. 常用组合方式有如下几种: 用vmstat.sar.iostat检测是否是CPU瓶颈 用free.vmstat检测是否是内存瓶颈 用iostat.dmesg 检测是否是磁盘I/O瓶颈 用netst ...

  5. 图像处理之opencv---mat、cvmat、IplImage之间的转换

    一.Mat类型:矩阵类型,Matrix.  在openCV中,Mat是一个多维的密集数据数组.可以用来处理向量和矩阵.图像.直方图等等常见的多维数据. Mat有3个重要的方法: 1.Mat mat = ...

  6. Nginx下的https配置

    https: https(Secure Hypertext Transfer Protocol) 安全超文本传输协议 它是以安全为目标的http通道,即它是http的安全版.它使用安全套接字层(SSL ...

  7. Entity Framework(EF)(一)之database first

    1.EF简介ADO.NET Entity Framework 是微软以 ADO.NET 为基础所发展出来的对象关系对应 (O/R Mapping) 解决方案.该框架曾经为.NET Framework的 ...

  8. Angular中的内置指令和自定义指令

    NG中的指令,到底是什么(what)? 为什么会有(why)?以及怎样使用(how)? What: 在NG中,指令扩展HTML功能,为 DOM 元素调用方法.定义行为绑定数据等. Why: 最大程度减 ...

  9. android实现跑马灯效果

    第一步:新建一个新项目,MarqueeTextView 首先为了观察到跑马灯效果,将要显示的文字极可能 写长.在strings.xml目录里面将 <string name="hello ...

  10. (转)findViewById 返回为null (自定义控件)

    一.自定义控件 findViewById返回为null 首先讲一个具体的问题,这几天在做demo时,写了一个自定义组合控件,最后在run的时候显示这两行报错.原先还以为是setOnClickListe ...