Description

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
我们用num记录有多少的*,拿x[i]记录第i行有多少*,拿y[j]记录第j列有多少*,有x[i]+y[j]==num+1||num的情况,就是符合要求的
#include<bits/stdc++.h>
using namespace std;
int n;
#define INF 1<<30
int L[200005];
int R[200005];
int num[200005];
string s;
int a; int main()
{
/*int coL=0;
int coR=0;
cin>>n;
cin>>s;
for(int i=0; i<n; i++)
{
cin>>num[i];
}
if(n==1)
{
puts("-1");
}
else
{
int MIN=INF;
for(int i=1; i<n; i++)
{
if(s[i]=='L'&&s[i-1]=='R')
{
MIN=min(MIN,num[i]-num[i-1]);
}
}
if(MIN==INF)
{
puts("-1");
}
else
{
printf("%d\n",MIN/2);
}
}*/
char a[1005][1005];
int ax[1100],bx[1100];
int n,m;
int num=0;
cin>>n>>m;
for(int i=0; i<n; i++)
{
scanf("%s",a[i]);
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
// cout<<a[i][j]<<" ";
if(a[i][j]=='*')
{
//cout<<"A"<<endl;
ax[i]++;
bx[j]++;
num++;
}
}
// cout<<endl;
}
// cout<<num<<endl;
int px=-1,py=-1;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(a[i][j]=='*')
{
if(ax[i]+bx[j]==num+1)
{
px=i;
py=j;
break;
}
}
else
{
if(ax[i]+bx[j]==num)
{
px=i;
py=j;
break;
}
}
}
}
if(px==-1||py==-1)
{
cout<<"NO"<<endl;
}
else
{
cout<<"YES"<<endl;
cout<<px+1<<" "<<py+1<<endl;
}
return 0;
}

  

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

  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)

    A题 http://codeforces.com/problemset/problem/699/A 非常的水,两个相向而行,且间距最小的点,搜一遍就是答案了. #include <cstdio& ...

  3. Codeforces Round #363 (Div. 1) B. Fix a Tree 树的拆环

    题目链接:http://codeforces.com/problemset/problem/698/B题意:告诉你n个节点当前的父节点,修改最少的点的父节点使之变成一棵有根树.思路:拆环.题解:htt ...

  4. Codeforces Round #363 (Div. 2) D. Fix a Tree —— 并查集

    题目链接:http://codeforces.com/contest/699/problem/D D. Fix a Tree time limit per test 2 seconds memory ...

  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) C. Vacations —— DP

    题目链接:http://codeforces.com/contest/699/problem/C 题解: 1.可知每天有三个状态:1.contest ,2.gym,3.rest. 2.所以设dp[i] ...

  7. Codeforces Round #363 (Div. 2)A-D

    699A 题意:在一根数轴上有n个东西以相同的速率1m/s在运动,给出他们的坐标以及运动方向,问最快发生的碰撞在什么时候 思路:遍历一遍坐标,看那两个相邻的可能相撞,更新ans #include< ...

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

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

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

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

  10. Codeforces Round #363 (Div. 2)->C. Vacations

    C. Vacations time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

随机推荐

  1. innerdb disable error

    innodb=OFF ignore-builtin-innodb skip-innodbdefault-storage-engine=myisam default-tmp-storage-engine ...

  2. 【C/C++】assert

    摘自http://www.cplusplus.com assert : macro #include <assert.h> void assert (int expression); 如果 ...

  3. 标准模板库(STL)学习指南之List链表

    本文转载自天极网,原文地址:http://www.yesky.com/255/1910755.shtml.转载请注明 什么是STL呢?STL就是Standard Template Library,标准 ...

  4. Javascript:必须知道的Javascript知识点之“单线程事件驱动”

    heiboard: Javascript:必须知道的Javascript知识点之“单线程事件驱动”

  5. Java程序打包成exe可执行文件

    前言: 我们都知道Java可以将二进制程序打包成可执行jar文件,双击这个jar和双击exe效果是一样一样的,但感觉还是不同.其实将java程序打包成exe也需要这个可执行jar文件. 准备: ecl ...

  6. CentOS 7关闭firewalld启用iptables

    在CentOS7中,有很多CentOS 6中的常用服务发生了变化. 其中iptables是其中比较大的一个.防火墙iptables被firewalld取代. 本文将介绍,如果采用systemctl关闭 ...

  7. POJ2513(字典树+图的连通性判断)

    //用map映射TLE,字典树就AC了#include"cstdio" #include"set" using namespace std; ; ;//26个小 ...

  8. 你可能还会遇到无法启动mysql的错误

    解决方法如下:

  9. shell入门-uniq去重复和tee重定向

    命令:uniq 选项:-c 显示重复数量 说明:去重复,不sort多个功能,显示几个重复 命令:tee 说明:重定向加上双重输出 [root@wangshaojun ~]# cat 2.txt1222 ...

  10. Spirng+In+Action(Craig Walls Ryan Breidenbach)

    目录 1.开始Spring之旅(简介) 2.装配Bean(IoC) 3.创建切面(AOP) ... 第一章:开始Spring之旅 1.1 为什么使用Spring:简化了企业级系统开发. 1.1.1 j ...