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/ ...
随机推荐
- hibernate 配置文件
hibernate.cfg.xml </session-factory> //DAO类 package com.hanqi.dao; import org.hibernate.Sessio ...
- 归并排序的go语言与C++实现对比
最近对go语言发生了兴趣,发现go语言语法简洁,非常适合算法的描述和实现,于是对归并排序进行了实现. 例子中需要排序的队列是长度为100的从100到1的数列,排序算法是正序排序,排序正确的话,结果应当 ...
- Html的Table与Echart的饼图实现联动效果
功能描述: 单击Table中的某个单元格,Echart的饼图加载相关的数据,鼠标悬停在Echarts饼图中的某一块中,Table显示与Echarts饼图相关的数据. 例:楼宇经济概要显示每一个季度所有 ...
- 已有打开的与此 Command 相关联的 DataReader,必须首先将它关闭
已有打开的与此 Command 相关联的 DataReader,必须首先将它关闭 引用: http://www.cnblogs.com/maxao/archive/2011/03/18/19881 ...
- Linux平台从文件中查找字符赋值于变量
以telnet方式登录Linux主机,在默认目录下用命令创建一个包含DUT wanIP的文本文件.[root] echo wanIP=88.0.100.253 > ./wanIP.txt在默认目 ...
- 在Activity之间传递数据—获取Activity返回的数据
在获取返回值时要注意的是打开Activity的方式,用方法:startActivityForResult 接收时,重写方法:onActivityResult 在子Activity中,写数据用方法:se ...
- linux top 命令---VIRT,RES,SHR,虚拟内存和物理内存(
VIRT,RES,SHR,虚拟内存和物理内存(转) VIRT: 1.进程"需要的"虚拟内存大小,包括进程使用的库.代码.数据,以及malloc.new分配的堆空间和分配的栈空间等: ...
- HDU2539:点球大战
Problem Description 在足球比赛中,有不少赛事,例如世界杯淘汰赛和欧洲冠军联赛淘汰赛中,当比赛双方经过正规比赛和加时赛之后仍然不分胜负时,需要进行点球大战来决定谁能够获得最终的胜利. ...
- linux 备份 文件+sql
sql 1 2 3 rm -f /bak/bak.sql mysqldump --databases nl -uroot -p413121 > /bak/bak.sql curl http:// ...
- 轻松创建nodejs服务器(1):一个简单nodejs服务器例子
这篇文章主要介绍了一个简单nodejs服务器例子,本文实现了一个简单的hello world例子,并展示如何运行这个服务器,需要的朋友可以参考下 我们先来实现一个简单的例子,hello world ...