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. HTML 5 canvas —— 基本语法

    目录 简述 canvas 基础 2D context API 基本线条 路径 插入图像 像素级操作 文字 阴影 颜色渐变 小节 简述 HTML 5 规范引进了很多新特性,其中最令人期待的之一就是 ca ...

  2. javascript jquery 常用方法

    javascript splice()   //删除数组成员 pop()   //删除数组成员 jquery $.type(aaa)  //判断对象类型

  3. InputStreamReader/OutputStreamWriter乱码问题解决

    /* *InputStreamReader参数charset要跟文件编码格式一致. InputStreamReader读的时候才不会乱码. *OutputStreamWriter参数charset设置 ...

  4. -bash: crontab: command not found(转)

    操作步骤 1. 确认crontab是否安装: 执行 crontab 命令如果报 command not found,就表明没有安装 2. 安装 crontab 执行 yum install -y vi ...

  5. CUDA编程

    目录: 1.什么是CUDA 2.为什么要用到CUDA 3.CUDA环境搭建 4.第一个CUDA程序 5. CUDA编程 5.1. 基本概念 5.2. 线程层次结构 5.3. 存储器层次结构 5.4. ...

  6. PostgreSQL Hardware Performance Tuning

    Bruce Momjian POSTGRESQL is an object-relational database developed on the Internet by a group of de ...

  7. Eclipse+Maven创建webapp项目<一><二><三>

    转-http://www.cnblogs.com/candle806/p/3439469.html Eclipse+Maven创建webapp项目<一> 1.开启eclipse,右键new ...

  8. 题目1049:字符串去特定字符——九度OJ

    题目1049:字符串去特定字符 http://ac.jobdu.com/problem.php?pid=1049 时间限制:1 秒 内存限制:32 兆 题目描述: 输入字符串s和字符c,要求去掉s中所 ...

  9. expression encoder 4 安装 出现“已经安排重启您的计算机

    问题: expression encoder 4  安装 出现“已经安排重启您的计算机 解决的办法,注册表数据的修改 开始 运行 regedit HKEY_LOCAL_MACHINE\SYSTEM\C ...

  10. C#-提取网页中的超链接

    转载:http://www.wzsky.net/html/Program/net/26849.htmlusing System; using System.Xml; using System.Text ...