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 ...
随机推荐
- 20179203李鹏举 《Linux内核原理与分析》第一周学习笔记
Linux基础入门 一.Linux的基础学习 1.1 Linux的重要基础操作 Linux不同于Windows的纯粹的图形化界面,虽然也有图形桌面的操作但是更多的操作还是通过命令行来进行,当然除了命令 ...
- bzoj 3012: [Usaco2012 Dec]First! Trie+拓扑排序
题目大意: 给定n个总长不超过m的互不相同的字符串,现在你可以任意指定字符之间的大小关系.问有多少个串可能成为字典序最小的串,并输出这些串.n <= 30,000 , m <= 300,0 ...
- ASP.NET AJAX(Atlas)和Anthem.NET——管中窥豹般小小比较
Anthem.NET近日有朋友和我提到Anthem.NET这个同样基于ASP.NET的Ajax框架,今天有机会亲自尝试了一下.初步的感觉似乎和ASP.NET AJAX不相上下,甚至某些地方要强于ASP ...
- Muduo 多线程模型:一个 Sudoku 服务器演变
陈硕 (giantchen AT gmail) blog.csdn.net/Solstice Muduo 全系列文章列表: http://blog.csdn.net/Solstice/category ...
- Operating System-进程/线程内部通信-竞争条件(Race Conditions)
从本文开始介绍进程间的通信,进程间通信遇到的问题以及方式其实和线程之间通信是一致的,所以进程间通信的所有理论知识都可以用在线程上,接下来的系列文章都会以进程之间的通信为模版进行介绍,本文主要内容: 进 ...
- Parallel Programming-Task Base
Parallel.For/ForEach是数据层面的并行,本文所讲的Task是将不同的操作并行执行,本文主要内容: Task的工作模型 初始化Task 完成Task 取消Task 一.Task工作模型 ...
- 通用RowMapper封装查询结果到自定义类中
package object; import java.lang.reflect.Field;import java.sql.ResultSet;import java.sql.SQLExceptio ...
- TS学习之变量声明
1.Var 声明变量 a)存在变量提升 (function(){ var a = "1"; var f = function(){}; var b = "2"; ...
- Android Studio的Android Monitor窗口中把标签拉出来之后放不回去的解决方法
不小心把下图方框中的logcat标签拖出来之后, 就变成了图2的浮动窗口,发现logcat标签怎么也弄不回原来窗口中的位置中. 其实解决方法很简单,只要拖住下图浮动窗口中红框位置的logcat标签,然 ...
- 用python做的windows和linx文件夹同步。解决自动同步、加快传输大量小文件的速度、更丰富的文件上传过滤设置。
现在工具不好用,用的pycharm自动同步,但对于git拉下来的新文件不能自动上传到linux,只有自己编辑过或者手动ctrl + s的文件才会自动同步.导致为了不遗漏文件,经常需要全量上传,速度非常 ...