B. One Bomb
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

Input

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.

Output

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.

Examples
input
  1. 3 4
    .*..
    ....
    .*..
output
  1. YES
    1 2
input
  1. 3 3
    ..*
    .*.
    *..
output
  1. NO
input
  1. 6 5
    ..*..
    ..*..
    *****
    ..*..
    ..*..
    ..*..
output
  1. YES
    3 3
    题意理解:一个人站在一个位置可以把同一行同一列的*消除,问有没有一个位置能够把所有的*消除,输出此坐标,没有则输出NO
    思路:记录*的总数sum并记录每一行a[i],每一列b[j],的*的数量,然后遍历,如果当前坐标s[i][j]=='*',此时叠了一个,将a[i]+b[j]-1sum做比较,相等则停止,输出当前坐标,
    如果当前坐标s[i][j]!='*',则直接a[i]+b[j]于sum做比较,相等则停止,输出当前坐标,否则输出NO
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int n,m,sum=;
  4. char s[][];
  5. int a[]= {},b[]= {};
  6. int main() {
  7. scanf("%d%d",&n,&m);
  8. for(int i=; i<=n; i++) {
  9. for(int j=; j<=m; j++) {
  10. cin>>s[i][j];
  11. if(s[i][j]=='*') {
  12. a[i]++;
  13. b[j]++;
  14. sum++;
  15. }
  16. }
  17. }
  18. for(int i=; i<=n; i++) {
  19. for(int j=; j<=m; j++) {
  20. int ss=a[i]+b[j];
  21. if(s[i][j]=='*')
  22. ss--;
  23. if(ss==sum) {
  24. printf("YES\n%d %d\n",i,j);
  25. return ;
  26. }
  27.  
  28. }
  29. }
  30. printf("NO\n");
  31. return ;
  32. }
  1.  

Codeforces Round #363 (Div. 2)->B. One Bomb的更多相关文章

  1. 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 ...

  2. Codeforces Round #363 (Div. 2) B. One Bomb —— 技巧

    题目链接:http://codeforces.com/contest/699/problem/B 题解: 首先统计每行每列出现'*'的次数,以及'*'出现的总次数,得到r[n]和c[m]数组,以及su ...

  3. Codeforces Round 363 Div. 1 (A,B,C,D,E,F)

    Codeforces Round 363 Div. 1 题目链接:## 点击打开链接 A. Vacations (1s, 256MB) 题目大意:给定连续 \(n\) 天,每天为如下四种状态之一: 不 ...

  4. Codeforces Round #363 (Div. 2) One Bomb

    One Bomb 题意: 只有一个炸弹,并且一个只能炸一行和一列的'*',问最后能否炸完所以'*',如果可以输出炸弹坐标 题解: 这题做的时候真的没什么好想法,明知道b题应该不难,但只会瞎写,最后越写 ...

  5. Codeforces Round #345 (Div. 1) E. Clockwork Bomb 并查集

    E. Clockwork Bomb 题目连接: http://www.codeforces.com/contest/650/problem/E Description My name is James ...

  6. Codeforces Round #363 (Div. 2)

    A题 http://codeforces.com/problemset/problem/699/A 非常的水,两个相向而行,且间距最小的点,搜一遍就是答案了. #include <cstdio& ...

  7. Codeforces Round #363 Div.2[111110]

    好久没做手生了,不然前四道都是能A的,当然,正常发挥也是菜. A:Launch of Collider 题意:20万个点排在一条直线上,其坐标均为偶数.从某一时刻开始向左或向右运动,速度为每秒1个单位 ...

  8. Codeforces Round #363 (Div. 1) B. Fix a Tree 树的拆环

    题目链接:http://codeforces.com/problemset/problem/698/B题意:告诉你n个节点当前的父节点,修改最少的点的父节点使之变成一棵有根树.思路:拆环.题解:htt ...

  9. Codeforces Round #363 (Div. 2) A、B、C

    A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

随机推荐

  1. iOS自定义NavigationBar

    日常开发中少不了用到UINavigationController,但是很多情况都要自定义NavigationBar.依稀记得自己刚开始也踩了好多坑,凑今天有空,就把想到的写下来.有时间了,考虑再把自定 ...

  2. 网站的配置文件XML读写

    网站的配置信息一般都写入到XML中,以下是简单的对xml的读写操作,仅供参考. 读操作: XmlDocument xmlDoc = new XmlDocument(); XmlReaderSettin ...

  3. windows 7 打开控制面板的命令

    在开始菜单中键入contrl,回车就进入了控制面板,比较快

  4. php折线图 布局图

    例子1: 1 <?php require_once("../conf.php"); ?> <!DOCTYPE HTML> <html> < ...

  5. ThinkPHP中的视图

    ThinkPHP中的视图View 1.什么是视图View 所谓的视图就是用户可视化操作界面. 2.视图View组成 view类(模板引擎类似Smarty) 模板文件(html模板) 3.视图的定义 默 ...

  6. const type& 与 type& 的区别

    const type& 与 type& 是C/C++编程中容易混淆的两个知识点,现在以 cont int& 与 int& 为例讲解: 1.int& 讲解 int ...

  7. 真正理解KMP算法

    作者:jostree 转载请注明出处 http://www.cnblogs.com/jostree/p/4403560.html 所谓KMP算法,就是判断一个模式串是否是一个字符串的子串,通常的算法当 ...

  8. jquery easyui combox实用方法记录

    // combogrid刷新 $(“#cc").combogrid('grid').datagrid('load'); // combogrid设置默认选中哪一行 $('#cc').comb ...

  9. Assembly(程序集) 反射和缓存

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  10. 使用 rem 实现 适配各种屏幕布局

    年数已久!!!技术更新太快,谨慎观看,不过作为了解一下思路还是可以的 在此呢,我只大略的谈一下在研究了px,em,rem,和手淘的做法之后,我所采用的做法及硬性规则: 我就不再过多的将上面三种单位的区 ...