Codeforces Round #363 (Div. 2) B. One Bomb (水题)
1 second
256 megabytes
standard input
standard output
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.
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.
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.
3 4
.*..
....
.*..
YES
1 2
3 3
..*
.*.
*..
NO
6 5
..*..
..*..
*****
..*..
..*..
..*..
YES
3 3
题意:
让你找一个点,放一个炸弹,使所有的*都被炸掉,炸弹只影响行列,和炸弹的那个点
题解:
行列统计一下又多少个*,然后暴力枚举每一个点,看这行这列的*的个数是否达到了全部的*的个数
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
#define pb push_back
#define F(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
typedef long long LL;
int n,m,anx,any,cnt=;
char g[][];
vector<int>Gu[],Gv[]; int main(){
scanf("%d%d",&n,&m);
F(i,,n){
getchar();
F(j,,m){
g[i][j]=getchar();
if(g[i][j]=='*'){
cnt++,anx=i,any=j;
Gu[i].pb(j);
Gv[j].pb(i);
}
}
}
if(cnt==){
printf("YES\n%d %d\n",anx,any);
return ;
}
F(i,,n)F(j,,m){
int ann=Gu[i].size()+Gv[j].size();
if(g[i][j]=='*')ann--;
if(ann==cnt){
printf("YES\n%d %d\n",i,j);
return ;
}
}
puts("NO");
return ;
}
Codeforces Round #363 (Div. 2) B. One Bomb (水题)的更多相关文章
- Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)
Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...
- Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题
A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...
- Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/675/problem/A Description Vasya likes e ...
- 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 ...
- Codeforces Round #363 (Div. 2) B. One Bomb —— 技巧
题目链接:http://codeforces.com/contest/699/problem/B 题解: 首先统计每行每列出现'*'的次数,以及'*'出现的总次数,得到r[n]和c[m]数组,以及su ...
- Codeforces Round #335 (Div. 2) B. Testing Robots 水题
B. Testing Robots Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606 ...
- Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题
A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...
- Codeforces Round #146 (Div. 1) A. LCM Challenge 水题
A. LCM Challenge 题目连接: http://www.codeforces.com/contest/235/problem/A Description Some days ago, I ...
- Codeforces Round #335 (Div. 2) A. Magic Spheres 水题
A. Magic Spheres Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606/ ...
随机推荐
- php 分页类(2)
<?phpinclude("connection.php");$perNumber=10; //每页显示的记录数$page=$_GET['page']; //获得当前的页面值 ...
- 在CentOS7部署zookeeper集群以及简单API使用
一.部署zookeeper集群 zookeeper是一个针对大型分布式系统的协调系统,提供的功能有统一名称服务.分布式同步等. 1.上传zk安装包 2.解压 tar -xzvf zookeep ...
- Webdriver实现下载功能,屏蔽掉windows弹出的对话框,FireFox下设置浏览器的属性,两种实现方式:
一.使用一个全新的FireFox浏览器打开Web应用,浏览器不带任何插件,也未对浏览器做任何默认配置,但需要对浏览器属性进行配置 // 获取浏览器的所有配置文件 ProfilesIni allProf ...
- HDU1577-WisKey的眼神
Problem Description WisKey的眼镜有500多度,所以眼神不大好,而且他有个习惯,就是走路喜欢看着地(不是为了拣钱哦^_^),所以大家下次碰见他的时候最好主动打下招呼,呵呵.但是 ...
- CodeForces 698B Fix a Tree (并查集应用)
当时也是想到了并查集,但是有几个地方没有想清楚,所以就不知道怎么写了,比如说如何确定最优的问题.赛后看了一下别人的思路,才知道自己确实经验不足,思维也没跟上. 其实没有那么复杂,这个题目我们的操作只有 ...
- CSS BFC(Block Formatting Context)
BFC是 W3C CSS 2.1 规范中的一个概念Block Formatting Context的缩写即格式化上下文,它决定了元素如何对其内容进行定位,以及与其他元素的关系和相互作用.简单讲,它是提 ...
- c语言_头文件_stdlib
简介 stdlib 头文件即standard library标准库头文件 stdlib 头文件里包含了C.C++语言的最常用的系统函数 该文件包含了C语言标准库函数的定义 stdlib.h里面定义了五 ...
- ios 控件 UIButton
- (void)setTitle:(NSString *)title forState:(UIControlState)state; //设置标题 - (void)setTitleColor:(UIC ...
- Postgres数据库在Linux中的I/O优化
I/O 优化1 打开 noatime方法: 修改 /etc/fstab2 调整预读方法: 查看 sudo blockdev --getra /dev/sda 设置 sudo blockdev --se ...
- Ansible7:Playbook常用模块【转】
playbook的模块与在ansible命令行下使用的模块有一些不同.这主要是因为在playbook中会使用到一些facts变量和一些通过setup模块从远程主机上获取到的变量.有些模块没法在命令行下 ...