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. CrtmpServr 接收Http流程

    最近在研究CrtmpServer http部分,记录一些基本的流程,以备查阅. 首先,打开配置脚本CrtmpServer.lua ,确认脚本中有以下内容,如果没有需要加上. { name=" ...

  2. Linq实现SQL in

    比如 Id in (1,2,3) int[] a={1,2,3}; list.Where(x=>a.Contains(x.Id))

  3. 文件I/O相关函数

    open()和openat()函数: #include <fcntl.h> // 成功返回文件描述符,出错返回-1 int open(const char *path, int oflag ...

  4. xadmin入门使用

    ,官方文档:http://xadmin.readthedocs.io/en/docs-chinese/views_api.html 中文文档:https://www.kancloud.cn/net_y ...

  5. 算法排序-lowB三人组

    冒泡排序思路: 选择排序思路: 插入排序思路: 小结: 详细代码解释看下一篇

  6. C# 比较两个数组中的内容是否相同的算法

    这里要比较的是两个数组中的内容是否相同,以int数组为例 int[] Arraya=new[] {1,2,3,4,5} int[] Arrayb=new[] {5,3,2,1,4} 以上两个数组内的值 ...

  7. Android组件系列----ContentProvider内容提供者【4】

    (4)单元測试类: 这里须要涉及到另外一个知识:ContentResolver内容訪问者. 要想訪问ContentProvider.则必须使用ContentResolver. 能够通过ContentR ...

  8. SAM4E单片机之旅——12、USART

    清楚了UART的用法之后,现在来研究一下USART的用法.和上一次差不多,这次也通过USART的串口来实现和PC的通信.和上一次不同的是,USART本身就有接收超时的功能,所以这次就不用TC了. US ...

  9. jquery 获取cookie的值 中文乱码的问题

    1.说明 测试环境asp.net mvc4,前台获取cookie的值需要引用js文件:  <script src="JS/jquery.cookie.js"></ ...

  10. 为编译器的实现者提供一个精确的定义:ANSI C

    编译器的实现 常用C++编译器推荐_w3cschool https://www.w3cschool.cn/cpp/cpp-zxm72ps8.html 常用C++编译器推荐 由 Alma 创建, 最后一 ...