Try Again

Coderfroces B. One Bomb

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 <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int row[1005],col[1005],pos,n,m;
char ch[1005][1005];
int main()
{
    memset(col,0,sizeof(col));
    memset(row,0,sizeof(row));
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>ch[i][j];
            if(ch[i][j]=='*')
            {
                row[i]++;
                col[j]++;
                pos++;
            }
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(ch[i][j]=='*')
            {
                if(row[i]+col[j]==pos+1)
                {
                    puts("YES");
                    cout<<i<<' '<<j<<endl;
                    return 0;
                }
            }
            else
            {
                if(row[i]+col[j]==pos)
                {
                    puts("YES");
                    cout<<i<<' '<<j<<endl;
                    return 0;
                }
            }
        }
    }
    puts("NO");
    return 0;
}

 

posted @ 2017-07-22 13:12  十年换你一句好久不见  阅读(136)  评论(0编辑  收藏  举报