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/ ...
随机推荐
- 基于PXE的Centos无人值守安装(Win平台)
一.环境准备 PXE服务器端 1.工具 tftpd32 (下载)用于提供DHCP和ftp服务 hfs (下载) 用于提供安装软件的http方式下载 Kickstart ...
- 用http-server 创建node.js 静态服务器
今天做一本书上的例子,结果代码不能正常运行,查询了一下,是语法过时了,书其实是新买的,出版不久. 过时代码如下 var connect=require('connect'); connect.crea ...
- jquery源码阅读(1)
每天坚持阅读一定量的的jquery代码,积少成多!加油加油! jquery-2.2.1的9161~9194行 1 if ( typeof define === "function" ...
- How to set a MySQL root user password in MAC OSX
https://www.youtube.com/watch?v=sFT9tGL54sI
- webdriver入门
webdriver是web自动化测试中的重要工具,通过webdriver可以灵活的操纵browser完成相关的测试,目前的webdriver对主流的浏览器均有支持, 如firefox ,chrome, ...
- Chapter 2 Open Book——13
"People in this town," he muttered. "Dr. Cullen is a brilliant surgeon who could prob ...
- 自动加载U盘
编辑/etc/fstab 比如想在开机的时候将/dev/sda1安装在/mnt 可以在/etc/fstab中加入一行 /dev/sda1 /mnt ext3 defaults 0 ...
- Python实战:爬虫的基础
网络爬虫(又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更经常的称为网页追逐者),是一种按照一定的规则,自动地抓取万维网信息的程序或者脚本.另外一些不常使用的名字还有蚂蚁.自动索引.模拟程序或者蠕 ...
- Django:之CMDB资源系统
渐谈CMDB需要内容,ITIL.CMDB介绍.Django自定义用户认证.Restful规范.资产管理功能开发. ITIL介绍 TIL即IT基础架构库(Information Technology I ...
- angular中的ng-bind-html指令和$sce服务
angular js的强大之处之一就是他的数据双向绑定这一牛B功能,我们会常常用到的两个东西就是ng-bind和针对form的ng-model.但在我们的项目当中会遇到这样的情况,后台返回的数据中带有 ...