B - B

CodeForces - 699B

题目:

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.

Input
The first line contains two positive integers n and m (1 ≤ n, m ≤ 1000) — the number of rows and columns in the depot field. The next n lines contain m symbols "." and "*" each — the description of the field. j-th symbol in i-th of them stands for cell (i, j). If the symbol is equal to ".", then the corresponding cell is empty, otherwise it equals "*" and the corresponding cell is occupied by a wall. Output
If it is impossible to wipe out all walls by placing and triggering exactly one bomb, then print "NO" in the first line (without quotes). Otherwise print "YES" (without quotes) in the first line and two integers in the second line — the coordinates of the cell at which the bomb should be laid. If there are multiple answers, print any of them. Examples
Input
3 4
.*..
....
.*..
Output
YES
1 2
Input
3 3
..*
.*.
*..
Output
NO
Input
6 5
..*..
..*..
*****
..*..
..*..
..*..
Output
YES
3 3

题意:输入一个n*m的矩阵,由*和. 分别表示墙和路,设置一个炸弹可以炸掉所在的行和列,问能不能放置一枚炸弹,炸掉所有的墙,若能,则输出“”YES“”,并在下一行输出炸弹坐标,否则输出“NO”

思路:用二维数组s[][] 输入,sum记录下墙的总数,同时用数组x[ ], y[ ] 记录下每一行和每一列的墙的总数目,最后遍历时对比

代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int x[1010]={0},y[1010]={0},sum=0;
char s[1010][1010];
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
cin>>s[i][j];
if(s[i][j]=='*')
{
sum++;
x[i]++;
y[j]++;
}
}
}
int q=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if((s[i][j]=='*'&&x[i]+y[j]-1==sum)||(s[i][j]!='*'&&x[i]+y[j]==sum))
{
q=1;
cout<<"YES"<<endl;
cout<<i+1<<" "<<j+1<<endl;
break;
}
}
if(q==1)break;
}
if(q==0)cout<<"NO"<<endl;
}

2021.2.23--vj补题的更多相关文章

  1. 2021.5.22 vj补题

    A - Marks CodeForces - 152A 题意:给出一个学生人数n,每个学生的m个学科成绩(成绩从1到9)没有空格排列给出.在每科中都有成绩最好的人或者并列,求出最好成绩的人数 思路:求 ...

  2. Educational Codeforces Round 23 A-F 补题

    A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...

  3. QFNU-ACM 2021.10.09 Rating补题

    A - A CodeForces - 478A 注意点: 和为0时要特判一下. 代码: #include<bits/stdc++.h> using namespace std; int m ...

  4. 2021-5-15 vj补题

    C - Win or Freeze CodeForces - 151C 题目内容: You can't possibly imagine how cold our friends are this w ...

  5. 20165237 2017-2018-2 《Java程序设计》第四周考试补做及2-3章编程题

    20165237 2017-2018-2 <Java程序设计>第四周考试补做及2-3章编程题 测试JDB: 用JDB调试上一个程序,输入1.2.3: 2-3章编程题代码托管 (程序的运行结 ...

  6. 2020.12.20vj补题

    A - Insomnia cure 题意:一共s只龙,每隔k,l,m,n只龙就会受伤,问这s只龙有多少龙是受伤的 思路:看起来题目范围并不是很多,直接进行循环判断 代码: 1 #include< ...

  7. hdu5017:补题系列之西安网络赛1011

    补题系列之西安网络赛1011 题目大意:给定一个椭球: 求它到原点的最短距离. 思路: 对于一个椭球的标准方程 x^2/a^2 + y^2/b^2 +z^2/c^2=1 来说,它到原点的最短距离即为m ...

  8. 2017河工大校赛补题CGH and 赛后小结

    网页设计课上实在无聊,便开始补题,发现比赛时候僵着的东西突然相通了不少 首先,"追妹"这题,两个队友讨论半天,分好多种情况最后放弃(可是我连题目都没看啊),今天看了之后试试是不是直 ...

  9. 2018 HDU多校第四场赛后补题

    2018 HDU多校第四场赛后补题 自己学校出的毒瘤场..吃枣药丸 hdu中的题号是6332 - 6343. K. Expression in Memories 题意: 判断一个简化版的算术表达式是否 ...

  10. 2018 HDU多校第三场赛后补题

    2018 HDU多校第三场赛后补题 从易到难来写吧,其中题意有些直接摘了Claris的,数据范围是就不标了. 如果需要可以去hdu题库里找.题号是6319 - 6331. L. Visual Cube ...

随机推荐

  1. Python3-sqlalchemy-orm 回滚

    #-*-coding:utf-8-*- #__author__ = "logan.xu" import sqlalchemy from sqlalchemy import crea ...

  2. Linux centos7 find 命令

    2021-08-13 1. 命令简介 find 命令用来在指定目录下查找文件.任何位于参数之前的字符串都将被视为欲查找的目录名.如果使用该命令时,不设置任何参数,则 find 命令将在当前目录下查找子 ...

  3. CSS3 animaion 和 transition 比较

    animation是CSS3的动画属性,可以设置以下六种属性. transition是CSS3的过度属性,可以设置以下四种属性. 从属性上分析,animation可以设定循环次数. 其次,两者的触发条 ...

  4. int索引转Excel列名(JavaScript版)

    indexToExcelColumn = (index)=>{       // 自然数     if (typeof index !== 'number') return false;    ...

  5. noip模拟43

    A. 第一题 儿子遍历顺序按深度由小到大即可 B. 第二题 二分最小值,以点权作为初始距离跑最长路即可 直接用大根堆跑 \(dij\) 会 \(T\),考虑初始权值可以处理,且边权一定,用类似蚯蚓的方 ...

  6. MongoDB 常见问题 - 解决找不到 mongo、mongod 命令的问题

    问题背景 成功安装 MongoDB 后执行 Mongo.MongoD 显示找不到命令 解决方案 echo 'export PATH="/usr/local/opt/mongodb-commu ...

  7. 通过url把第一个页面的数据传到第二页面

    第一个页面: function GetQueryString(name) { var reg = new RegExp("(^|&)"+ name +"=([^& ...

  8. linu命令进阶篇

    预备知识: 本实验要求实验者具备如下的相关知识. 前面我们学习了linux的文件系统,了解的文件系统的结构,也学了linux档案的属性和权限,以及其设定. 当我们执行命令操作一个文件的时候,却不知道这 ...

  9. el-upload + accept限制上传的文件格式

    /**  * kevin 2021/1/4  * @description el-upload + accept限制上传的文件格式  * @param e 校验的类型  * @returns {str ...

  10. python库--jieba(中文分词)

    import jieba 精确模式,试图将句子最精确地切开,适合文本分析:全模式,把句子中所有的可以成词的词语都扫描出来, 速度非常快,但是不能解决歧义:搜索引擎模式,在精确模式的基础上,对长词再次切 ...