题目链接: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. java正则表达式的知识

    /** 用途:正则表达式 * 创建人:向家康 * 创建日期:2019年4月21日 下午9:59:08 */ //有了登录界面当然少不了正则表达式啦,这是做项目必备的知识点 //通过本博客的代码,想必即 ...

  2. 扩展欧几里得算法(exGCD)学习笔记

    @(学习笔记)[扩展欧几里得] 本以为自己学过一次的知识不会那么容易忘记, 但事实证明, 两个星期后的我就已经不会做扩展欧几里得了...所以还是写一下学习笔记吧 问题概述 求解: \[ax + by ...

  3. JDBC_完整版

    1,新建WEB项目:JDBC 2,导入驱动 将mysql-connector-java-5.0.8-bin.jar包放入web-inf目录下面的lib目录中 3,新建User类,放入entity包中 ...

  4. javascript --- 原型继承与属性拷贝的综合应用

    对于继承来说,主要目标就是将一些现有的功能据为己有.也就是说,我们在新建一个对象的时候,通常首先继承现有对象,然后再为其添加额外的属性和方法. 对此,我们可以通过一个函数调用来完成. 具体而言就是: ...

  5. python--文本处理1

    1.字符和字符值之间的转换 内建函数:ord(),chr() >>> print ord("a") 97 >>> print chr(97) a ...

  6. android 获取GPS定位

    AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xm ...

  7. java资源分享、面试题资料、分布式大数据

    马士兵大数据_架构师(1) 链接:http://pan.baidu.com/s/1qYTW1m0 密码:lxjd spring Cloud 链接:http://pan.baidu.com/s/1bzG ...

  8. HashMap 和 Hashtable 的同和不同

    综述 可以直接根据 hashcode 值判断两个对象是否相等吗?肯定是不可以的,因为不同的对象可能会生成相同的 hashcode 值.虽然不能根据 hashcode 值判断两个对象是否相等,但是可以直 ...

  9. mysql_config_editor使用简介

      原文 : http://blog.itpub.net/29773961/viewspace-1817640/   ----------------------------------------- ...

  10. HDU 4403 A very hard Aoshu problem (DFS暴力)

    题意:给你一个数字字符串.问在字符串中间加'='.'+'使得'='左右两边相等. 1212  : 1+2=1+2,   12=12. 12345666 : 12+3+45+6=66.  1+2+3+4 ...