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<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#define pb push_back
#define F(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
typedef long long LL;
int n,m,anx,any,cnt=;
char g[][];
vector<int>Gu[],Gv[]; int main(){
scanf("%d%d",&n,&m);
F(i,,n){
getchar();
F(j,,m){
g[i][j]=getchar();
if(g[i][j]=='*'){
cnt++,anx=i,any=j;
Gu[i].pb(j);
Gv[j].pb(i);
}
}
}
if(cnt==){
printf("YES\n%d %d\n",anx,any);
return ;
}
F(i,,n)F(j,,m){
int ann=Gu[i].size()+Gv[j].size();
if(g[i][j]=='*')ann--;
if(ann==cnt){
printf("YES\n%d %d\n",i,j);
return ;
}
}
puts("NO");
return ;
}

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

  1. Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)

    Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...

  2. Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题

    A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...

  3. Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题

    A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/675/problem/A Description Vasya likes e ...

  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 #335 (Div. 2) B. Testing Robots 水题

    B. Testing Robots Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606 ...

  7. Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题

    A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...

  8. Codeforces Round #146 (Div. 1) A. LCM Challenge 水题

    A. LCM Challenge 题目连接: http://www.codeforces.com/contest/235/problem/A Description Some days ago, I ...

  9. Codeforces Round #335 (Div. 2) A. Magic Spheres 水题

    A. Magic Spheres Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606/ ...

随机推荐

  1. 1.编写一个Java应用程序,该程序中有3个类:Ladder、Circle和主类A。具体要求如下:Ladder类具有类型为double的上底、下底、高、面积属性,具有返回面积的功能,包括一个构造方法对上底、下底、高进行初始化。Circle类具有类型为double的半径、周长和面积属性,具有返回周长、面积的功能,包括一个构造方法对半径进行初始化。主类A用来测试类Ladder和类Circle的功能。

    Ladder package com.hanqi.test; public class Ladder { //属性 double shangdi,xiadi,gao,mianji; //构造方法 La ...

  2. Fiddler AutoResponder正则替换

    今天感冒,写简单些. Fiddler AutoResponder正则替换: regex:(?inx).+20150826_1_1_386.mp4/playlist.m3u8.*$ .表示任意字符 *: ...

  3. Thrift源码解析--transport

    这一层主要是用于实现网络通信,现在都是基于Tcp/Ip,而Tcp/Ip协议栈由socket来实现,换句话说就是现在网络通信服务底层大都是通过socket实现的,在thrift源码中,就是将socket ...

  4. HDU 2722 Here We Go(relians) Again (spfa)

    Here We Go(relians) Again Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/ ...

  5. Vim 配置Markdown

    通过vundle工具安装以下插件: vim-markdown   语法高亮 vim-markdown-preview.vim  通过浏览器实时预览(支持同步滚动) -/.vimrc vundle部分添 ...

  6. sql语句--查询语句(MySQL)

    1.截取字符串 left(str, length),right(str, length),substring(str, pos, length) 原文:http://www.jb51.net/arti ...

  7. 交互式shell和非交互式shell的区别

    交互式模式就是shell等待你的输入,并且执行你提交的命令.这种模式被称作交互式是因为shell与用户进行交互.这种模式也是大多数用户非常熟悉的:登录.执行一些命令.签退.当你签退后,shell也终止 ...

  8. 二分图匹配之KM求二分图最佳匹配算法

    参考网址:http://blog.163.com/suntroop@yeah/blog/static/17012103120115185927194/ 对于具有二部划分( V1, V2 )的加权完全二 ...

  9. javascript 浏览器

    hashchange事件 window.location.hash.slice(1) 添加和修改历史记录条目LINKHTML5引进了history.pushState()方法和history.repl ...

  10. PHP set_error_handler()函数的使用【转载】

    我们写程序,难免会有问题(是经常会遇到问题 ),而PHP遇到错误时,就会给出出错脚本的位置.行数和原因.有很多人说,这并没有什么大不了.确实,在调试程序阶段,这确实是没啥的,而且我认为给出错误路径是必 ...