Codeforces Round #363 (Div. 2) B
Description
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
我们用num记录有多少的*,拿x[i]记录第i行有多少*,拿y[j]记录第j列有多少*,有x[i]+y[j]==num+1||num的情况,就是符合要求的
#include<bits/stdc++.h>
using namespace std;
int n;
#define INF 1<<30
int L[200005];
int R[200005];
int num[200005];
string s;
int a; int main()
{
/*int coL=0;
int coR=0;
cin>>n;
cin>>s;
for(int i=0; i<n; i++)
{
cin>>num[i];
}
if(n==1)
{
puts("-1");
}
else
{
int MIN=INF;
for(int i=1; i<n; i++)
{
if(s[i]=='L'&&s[i-1]=='R')
{
MIN=min(MIN,num[i]-num[i-1]);
}
}
if(MIN==INF)
{
puts("-1");
}
else
{
printf("%d\n",MIN/2);
}
}*/
char a[1005][1005];
int ax[1100],bx[1100];
int n,m;
int num=0;
cin>>n>>m;
for(int i=0; i<n; i++)
{
scanf("%s",a[i]);
}
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
// cout<<a[i][j]<<" ";
if(a[i][j]=='*')
{
//cout<<"A"<<endl;
ax[i]++;
bx[j]++;
num++;
}
}
// cout<<endl;
}
// cout<<num<<endl;
int px=-1,py=-1;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(a[i][j]=='*')
{
if(ax[i]+bx[j]==num+1)
{
px=i;
py=j;
break;
}
}
else
{
if(ax[i]+bx[j]==num)
{
px=i;
py=j;
break;
}
}
}
}
if(px==-1||py==-1)
{
cout<<"NO"<<endl;
}
else
{
cout<<"YES"<<endl;
cout<<px+1<<" "<<py+1<<endl;
}
return 0;
}
Codeforces Round #363 (Div. 2) B的更多相关文章
- Codeforces Round 363 Div. 1 (A,B,C,D,E,F)
Codeforces Round 363 Div. 1 题目链接:## 点击打开链接 A. Vacations (1s, 256MB) 题目大意:给定连续 \(n\) 天,每天为如下四种状态之一: 不 ...
- Codeforces Round #363 (Div. 2)
A题 http://codeforces.com/problemset/problem/699/A 非常的水,两个相向而行,且间距最小的点,搜一遍就是答案了. #include <cstdio& ...
- Codeforces Round #363 (Div. 1) B. Fix a Tree 树的拆环
题目链接:http://codeforces.com/problemset/problem/698/B题意:告诉你n个节点当前的父节点,修改最少的点的父节点使之变成一棵有根树.思路:拆环.题解:htt ...
- Codeforces Round #363 (Div. 2) D. Fix a Tree —— 并查集
题目链接:http://codeforces.com/contest/699/problem/D D. Fix a Tree time limit per test 2 seconds memory ...
- Codeforces Round #363 (Div. 2) B. One Bomb —— 技巧
题目链接:http://codeforces.com/contest/699/problem/B 题解: 首先统计每行每列出现'*'的次数,以及'*'出现的总次数,得到r[n]和c[m]数组,以及su ...
- Codeforces Round #363 (Div. 2) C. Vacations —— DP
题目链接:http://codeforces.com/contest/699/problem/C 题解: 1.可知每天有三个状态:1.contest ,2.gym,3.rest. 2.所以设dp[i] ...
- Codeforces Round #363 (Div. 2)A-D
699A 题意:在一根数轴上有n个东西以相同的速率1m/s在运动,给出他们的坐标以及运动方向,问最快发生的碰撞在什么时候 思路:遍历一遍坐标,看那两个相邻的可能相撞,更新ans #include< ...
- Codeforces Round #363 Div.2[111110]
好久没做手生了,不然前四道都是能A的,当然,正常发挥也是菜. A:Launch of Collider 题意:20万个点排在一条直线上,其坐标均为偶数.从某一时刻开始向左或向右运动,速度为每秒1个单位 ...
- Codeforces Round #363 (Div. 2) One Bomb
One Bomb 题意: 只有一个炸弹,并且一个只能炸一行和一列的'*',问最后能否炸完所以'*',如果可以输出炸弹坐标 题解: 这题做的时候真的没什么好想法,明知道b题应该不难,但只会瞎写,最后越写 ...
- Codeforces Round #363 (Div. 2)->C. Vacations
C. Vacations time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
随机推荐
- bzoj 2007 海拔 —— 最短路
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2007 最后一定是起点周围一片0,终点周围一片1: 所以建出图来跑最短路即可. 代码如下: # ...
- vi查找替换命令详解
一.查找 查找命令 /pattern<Enter> :向下查找pattern匹配字符串 ?pattern<Enter>:向上查找pattern匹配字符串 使用了查找命令之后,使 ...
- C++输入输出知识
1.strtok将字符串中的单词用' '分割出来 #include<iostream> #include<cstdio> #include<cstdlib> #in ...
- 问题:oracle nvl;结果:Oracle中的NVL函数
Oracle中的NVL函数 (2012-11-30 13:21:43) 转载▼ 标签: nvl oracle 分类: Oracle Oracle中函数以前介绍的字符串处理,日期函数,数学函数,以及转换 ...
- ubunt14.04搭建lNMP
一.安装mysql 1. sudo apt-get update 2. sudo apt-get install apt-get nginx 二.安装mysql 1. sudo apt-get ...
- cisco 2901 配置拨号上网
1.输入en,然后输入密码确认后按conf t2.Router(config)# vpdn enable interface dialer 1 // 进入拨号器13.Router(c ...
- 网络编程之socket编程
TCP/IP协议 网络层的“ip地址”可以唯一标识网络中的主机,而传输层的“协议+端口”可以唯一标识主机中的应用程序(进程).这样利用三元组(ip地址,协议,端口)就可以标识网络的进程了,网络中的进程 ...
- 【问题】Expandable数据集的定义的正确方法,TabActivity弃用替代,Gallery替代,imageswitcher
Expandable 问题: http://www.cnblogs.com/xingyyy/p/3389611.html 扩展阅读:http://blog.csdn.net/lmj623565791/ ...
- Java泛型通配符以及限定
摘抄笔记 A:泛型的限定 /* * 将的酒店员工,厨师,服务员,经理,分别存储到3个集合中 * 定义方法,可以同时遍历3集合,遍历三个集合的同时,可以调用工作方法 */ import java.uti ...
- 六种获取配置properties文件的方法
总结一下六种获取配置properties文件的方法,代码如下: package com.xujingyang.test ; import java.io.BufferedInputStream ; i ...