One Bomb

题意:

只有一个炸弹,并且一个只能炸一行和一列的‘*’,问最后能否炸完所以‘*’,如果可以输出炸弹坐标

题解:

这题做的时候真的没什么好想法,明知道b题应该不难,但只会瞎写,最后越写越乱,我就放弃了。看了题解,果然还是我不行。。。

首先枚举一遍,记录总‘*'数,和每行,每列的‘*’数,之后再枚举一遍,看是否一行一列的‘*’数和总‘*'数相等,如果是,那就是答案,如果没有,就是NO。

代码:

#include <bits/stdc++.h>
using namespace std; typedef long long ll;
const int INF=0x3f3f3f3f;
const ll LINF=0x3f3f3f3f3f3f3f3f;
#define PI(A) cout<<A<<endl
#define SI(N) cin>>N
#define SII(N,M) cin>>N>>M
#define cle(a,val) memset(a,(val),sizeof(a))
#define rep(i,b) for(int i=0;i<(b);i++)
#define Rep(i,a,b) for(int i=(a);i<=(b);i++)
#define reRep(i,a,b) for(int i=(a);i>=(b);i--)
#define dbg(x) cout <<#x<<" = "<<x<<endl
#define PIar(a,n) rep(i,n)cout<<a[i]<<" ";cout<<endl;
#define PIarr(a,n,m) rep(aa,n){rep(bb, m)cout<<a[aa][bb]<<" ";cout<<endl;}
const double EPS= 1e-9 ; /* ///////////////////////// C o d i n g S p a c e ///////////////////////// */ const int MAXN= 1000 + 9 ; string s[MAXN];
int a[MAXN],b[MAXN];
int N,M; int main()
{
iostream::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
while(SII(N,M))
{
cle(a,0);
cle(b,0);
rep(i,N) SI(s[i]);
ll wall=0;
rep(i,N)
{
rep(j,M)
if (s[i][j]=='*')
{
wall++;
a[i]++;
b[j]++;
}
}
bool fl=0;
int ax=0,ay=0;
rep(i,N)
{
rep(j,M)
{
ll ans=a[i]+b[j]-(s[i][j]=='*'?1:0);
if (ans==wall)
{
fl=1;
ax=i,ay=j;
}
}
}
if(fl)
{
puts("YES");
printf("%d %d\n",ax+1,ay+1);
}
else puts("NO");
}
return 0;
}

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

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

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

  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. 2) B. One Bomb (水题)

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

  4. Codeforces Round #363 (Div. 2) B. One Bomb —— 技巧

    题目链接:http://codeforces.com/contest/699/problem/B 题解: 首先统计每行每列出现'*'的次数,以及'*'出现的总次数,得到r[n]和c[m]数组,以及su ...

  5. Codeforces Round #363 (Div. 2)

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

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

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

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

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

  8. 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 ...

  9. Codeforces Round #363 (Div. 2) B

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

随机推荐

  1. scala言语基础学习十二

  2. Unity Shader _Time

    _Time是个4维向量,跟Unity3D中的deltaTime(这是个一维的,数值)不同. float4 _Time : Time (t/20, t, t*2, t*3), use to animat ...

  3. c语言学习笔记

    为什么需要输出控制符: 1:  01组成的代码可以表示数据亦可以表示指令: 2:如果01组成的代码表示的是数据的话,那么同样的01代码组合以不同的输出格式输出就会有不同的输出结果.. %d   --- ...

  4. 【转贴】Cortex系列M0-4简单对比

    转载网址:http://blog.sina.com.cn/s/blog_7dbd9c0e01018e4l.html 最近搞了块ST的Cortex-M4处理器,然后下了本文档.分享一下. 针对目前进入大 ...

  5. feature visualization from ipython notebook

    Feature visualization from ipython notebook Wang Xiao 1. install anaconda2 from: https://www.continu ...

  6. C#综合揭秘——深入分析委托与事件

    http://www.cnblogs.com/leslies2/archive/2012/03/22/2389318.html 引言 本篇文章将为你介绍一下 Delegate 的使用方式,逐渐揭开 C ...

  7. SQL Server中数据库文件的存放方式,文件和文件组

    原文地址:http://www.cnblogs.com/CareySon/archive/2011/12/26/2301597.html   SQL Server中数据库文件的存放方式,文件和文件组 ...

  8. Vs 2013 单步调试 .net framework 中遇到的问题

    为了可以看清.net framework 的的内部机制,进行单步实际是不错的选择啊,   其它的更多设置可以看其它文章,我这里主要讲问题.     然后就会加载PDB,然后就可以单步进入了. 但是 , ...

  9. linux服务之varnish

    https://www.varnish-cache.org/installation/redhatvarnish是现在很流行的一个HTTP(80)缓存加速解决方案,varnish是基于内存的缓存加速. ...

  10. pythonchallenge关卡破解

    第一关:pow(2,38) 第二关: import string table = str.maketrans(string.ascii_lowercase, string.ascii_lowercas ...