题目链接:http://codeforces.com/contest/699/problem/B

题解:

首先统计每行每列出现‘*’的次数,以及‘*’出现的总次数,得到r[n]和c[m]数组,以及sum,。然后再枚举每一个格子(O(n^2)枚举,反正输入都是枚举的)。

对于每一个格子s[i][j]:

1.如果它是‘*’, 那么当 r[i] + c[j] - 1 = sum 时, 表明炸弹放在这个位置可以炸掉所有的墙。

2.如果它是‘.’, 那么当 r[i] + c[j] = sum 时, 表明炸弹放在这个位置可以炸掉所有的墙。

这个规律还是要画图才比较好找出来的……

代码如下:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <sstream>
#include <algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define ms(a, b) memset((a), (b), sizeof(a))
#define eps 0.0000001
typedef long long LL;
const int INF = 2e9;
const LL LNF = 9e18;
const int mod = 1e9+7;
const int maxn = 200000+10; int n,m;
char s[1005][1005];
int r[1005], c[1005]; void init()
{
scanf("%d%d",&n,&m);
for(int i = 1; i<=n; i++)
scanf("%s",s[i]+1); ms(c,0);
ms(r,0);
} void solve()
{
int sum = 0;
for(int i = 1; i<=n; i++)
for(int j = 1; j<=m; j++)
if(s[i][j] == '*')
sum++, r[i]++, c[j]++; int B = 0, x, y;
for(int i = 1; i<=n; i++)
for(int j = 1; j<=m; j++)
{
int tmp = r[i]+c[j];
if(s[i][j]=='*')
tmp--; if(tmp==sum)
{
B = 1;
x = i; y = j;
break;
}
} if(B)
printf("YES\n%d %d\n",x,y);
else
puts("NO");
} int main()
{
// int T;
// scanf("%d",&T);
// while(T--)
{
init();
solve();
}
return 0;
}

Codeforces Round #363 (Div. 2) B. One Bomb —— 技巧的更多相关文章

  1. 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 input ou ...

  2. 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 input ou ...

  3. Codeforces Round 363 Div. 1 (A,B,C,D,E,F)

    Codeforces Round 363 Div. 1 题目链接:## 点击打开链接 A. Vacations (1s, 256MB) 题目大意:给定连续 \(n\) 天,每天为如下四种状态之一: 不 ...

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

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

  5. Codeforces Round #345 (Div. 1) E. Clockwork Bomb 并查集

    E. Clockwork Bomb 题目连接: http://www.codeforces.com/contest/650/problem/E Description My name is James ...

  6. Codeforces Round #363 (Div. 2)

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

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

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

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

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

  9. Codeforces Round #363 (Div. 2) A、B、C

    A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

随机推荐

  1. 洛谷—— P1577 切绳子

    https://www.luogu.org/problemnew/show/P1577 题目描述 有N条绳子,它们的长度分别为Li.如果从它们中切割出K条长度相同的 绳子,这K条绳子每条最长能有多长? ...

  2. 数据结构------------------二叉查找树(BST)的java实现

    数据结构------------------二叉查找树(BST)的java实现 二叉查找树(BST)是一种能够将链表插入的灵活性和有序数组查找的高效性相结合的一种数据结构.它的定义如下: 二叉查找树是 ...

  3. Tensorflow 之 TensorBoard可视化Graph和Embeddings

    windows下使用tensorboard tensorflow 官网上的例子程序都是针对Linux下的:文件路径需要更改 tensorflow1.1和1.3的启动方式不一样 :参考:Running ...

  4. Opencv 改进的外接矩形合并拼接方法

    上一篇中的方法存在的问题是矩形框不够精确,而且效果不能达到要求 这里使用凸包检测的方法,并将原来膨胀系数由20缩小到5,达到了更好的效果 效果图: 效果图: 代码: #include <open ...

  5. mysql 授权新的root用户

    grant all privileges to *.* on system@'localhost' identified by 'woshishui' with grant option;

  6. mysql freeing items 状态

    http://blog.sina.com.cn/s/blog_6128a8f00100wsdd.html数据库出现大量的freeing items状态 表更新慢 而且大量锁表查看mysql官方free ...

  7. jquery $.proxy使用 Jquery实现ready()的源码

    jquery $.proxy使用   在某些情况下,我们调用Javascript函数时候,this指针并不一定是我们所期望的那个.例如: 1 //正常的this使用 2 $('#myElement') ...

  8. linux SPI驱动——简单的gpio模拟SPI驱动测试 (二)

    1: /* 2: * Add by xuyonghong for duotin car radio fm 3: * Copyright (C) 2016-5-24 xuyonghong@duotin. ...

  9. [Phoenix] 五、二级索引

    摘要: 目前HBASE只有基于字典序的主键索引,对于非主键过滤条件的查询都会变成扫全表操作,为了解决这个问题Phoenix引入了二级索引功能.然而此二级索引又有别于传统关系型数据库的二级索引,本文将详 ...

  10. Java之运行时异常与编译时异常区别

    Java中用2种方法处理异常: 1.在发生异常的地方直接处理: 2.将异常抛给调用者,让调用者处理. Java异常可分为3种: (1)编译时异常:Java.lang.Exception (2)运行期异 ...