One Bomb

原创 2016年08月28日 17:58:48
链接:

题目:

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.



题意:给一个雷区域,问能否找到一个点,该点所在的行和列包含所有的雷


分析:暴力,记录区域,记录每行多少雷,每列多少雷,遍历所有点,看行列和是否等于总数。

题解:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <cmath>
#include <cctype>
#include <cfloat>
#include <climits>
#include <complex>
#include <deque>
#include <list>
#include <set>
#include <utility>

#define fi(x) for(int i=0;i<x;i++)
#define fj(x) for(int j=0;j<x;j++)
#define fk(x) for(int k=0;k<x;k++)
#define fid(x) for(int i=x-1;i>=0;i--)
#define fjd(x) for(int j=x-1;j>=0;j--)
#define fkd(x) for(int k=x-1;k>=0;k--)
#define fi1(x) for(int i=1;i<=x;i++)
#define fj1(x) for(int j=1;j<=x;j++)
#define fk1(x) for(int k=1;k<=x;k++)
#define fi1d(x) for(int i=x;i>0;i--)
#define fj1d(x) for(int j=x;j>0;j--)
#define fk1d(x) for(int k=x;k>0;k--)

using namespace std;

int x[1010], y[1010];
char s[1010][1010];


int main()
{
	//freopen("in.txt", "r", stdin);
	int n, m, num;
	char temp;
	cin >> n >> m;
	num = 0;
	fi(n)
		fj(m) {
		cin >> temp;
		if (temp == '*')
		{
			x[i + 1]++;
			y[j + 1]++;
			num++;
			s[i + 1][j + 1] = '*';
		}
	}
	fi1(n)
		fj1(m) {
		int tn = x[i] + y[j];
		if (s[i][j] == '*')
		{
			tn--;
		}
		if (tn == num)
		{
			cout << "YES\n" << i << ' ' << j << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Codeforces Round #363 (Div. 2) B. One Bomb (水题)

B. One Bomb time limit per test 1 second memory limit per test 256 megabytes input ...

One Bomb

Description You are given a description of a depot. It is a rectangular checkered field of n × ...

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

You are given a description of a depot. It is a rectangular checkered field of n × m size. Each cell...

Codeforces-Round-#363- One Bomb

Codeforces-Round-#363- One Bomb

B. One Bomb(水题)

B. One Bomb time limit per test 1 second memory limit per test 256 megabytes input ...

Codeforces Round #363(Div. 2) A. Launch of Collider【模拟】 && B. One Bomb【暴力】

Codeforces Round #363(Div. 2) A. Launch of Collider【模拟】 && B. One Bomb【暴力】

【打CF,学算法——二星级】Codeforces 699B - One Bomb (技巧)

【CF简介】 题目链接:CF 699B 题面: B. One Bomb time limit per test 1 second memory ...

codeforces 699B One Bomb (思维)

B. One Bomb time limit per test 1 second memory limit per test 256 megabytes input ...

CodeForces - 699B One Bomb 一颗炸弹 基础题 打表

CF传送门 题意: 1. 一张地图(二维数组建立的图)上存在墙(*)和空地(.) 2. 给你一颗炸弹,要求放在地图上的某一点可以炸毁所有墙,炸弹可以无视距离炸毁上下左右四个方向所有东西 3...

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 in...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:One Bomb
举报原因:
原因补充:

(最多只允许输入30个字)