【Codeforces Round 363 (Div 2) B】【水题 行列计数】One Bomb 炸弹人爆破游戏

来源:互联网 发布:淘宝客服工作描述 编辑:程序博客网 时间:2024/06/04 19:08

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
YES1 2
input
3 3..*.*.*..
output
NO
input
6 5..*....*..*****..*....*....*..
output
YES3 3

#include<stdio.h>#include<iostream>#include<string.h>#include<string>#include<ctype.h>#include<math.h>#include<set>#include<map>#include<vector>#include<queue>#include<bitset>#include<algorithm>#include<time.h>using namespace std;void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }#define MS(x,y) memset(x,y,sizeof(x))#define MC(x,y) memcpy(x,y,sizeof(x))#define MP(x,y) make_pair(x,y)#define ls o<<1#define rs o<<1|1typedef long long LL;typedef unsigned long long UL;typedef unsigned int UI;template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }const int N = 1010, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;int n, m;char a[N][N];int line[N][N];int list[N][N];int main(){while (~scanf("%d%d", &n, &m)){int sum = 0;for (int i = 1; i <= n; ++i){scanf("%s", a[i] + 1);for (int j = 1; j <= m; ++j){line[i][j] = line[i][j - 1] + (a[i][j] == '*');list[i][j] = list[i - 1][j] + (a[i][j] == '*');sum += a[i][j] == '*';}}bool flag = 0;for (int i = 1; i <= n; ++i){for (int j = 1; j <= m; ++j){if (sum == line[i][m] + list[n][j] - (a[i][j] == '*')){flag = 1;puts("YES");printf("%d %d\n", i, j);break;}if (flag)break;}if (flag)break;}if (!flag)puts("NO");}return 0;}


0 0
原创粉丝点击