本文主要是介绍【Codeforces Round 363 (Div 2) B】【水题 行列计数】One Bomb 炸弹人爆破游戏,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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.
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.
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.
3 4 .*.. .... .*..
YES 1 2
3 3 ..* .*. *..
NO
6 5 ..*.. ..*.. ***** ..*.. ..*.. ..*..
YES 3 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|1
typedef 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;
}
这篇关于【Codeforces Round 363 (Div 2) B】【水题 行列计数】One Bomb 炸弹人爆破游戏的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!