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.

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
    我们用num记录有多少的*,拿x[i]记录第i行有多少*,拿y[j]记录第j列有多少*,有x[i]+y[j]==num+1||num的情况,就是符合要求的
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int n;
  4. #define INF 1<<30
  5. int L[200005];
  6. int R[200005];
  7. int num[200005];
  8. string s;
  9. int a;
  10.  
  11. int main()
  12. {
  13. /*int coL=0;
  14. int coR=0;
  15. cin>>n;
  16. cin>>s;
  17. for(int i=0; i<n; i++)
  18. {
  19. cin>>num[i];
  20. }
  21. if(n==1)
  22. {
  23. puts("-1");
  24. }
  25. else
  26. {
  27. int MIN=INF;
  28. for(int i=1; i<n; i++)
  29. {
  30. if(s[i]=='L'&&s[i-1]=='R')
  31. {
  32. MIN=min(MIN,num[i]-num[i-1]);
  33. }
  34. }
  35. if(MIN==INF)
  36. {
  37. puts("-1");
  38. }
  39. else
  40. {
  41. printf("%d\n",MIN/2);
  42. }
  43. }*/
  44. char a[1005][1005];
  45. int ax[1100],bx[1100];
  46. int n,m;
  47. int num=0;
  48. cin>>n>>m;
  49. for(int i=0; i<n; i++)
  50. {
  51. scanf("%s",a[i]);
  52. }
  53. for(int i=0;i<n;i++)
  54. {
  55. for(int j=0;j<m;j++)
  56. {
  57. // cout<<a[i][j]<<" ";
  58. if(a[i][j]=='*')
  59. {
  60. //cout<<"A"<<endl;
  61. ax[i]++;
  62. bx[j]++;
  63. num++;
  64. }
  65. }
  66. // cout<<endl;
  67. }
  68. // cout<<num<<endl;
  69. int px=-1,py=-1;
  70. for(int i=0;i<n;i++)
  71. {
  72. for(int j=0;j<m;j++)
  73. {
  74. if(a[i][j]=='*')
  75. {
  76. if(ax[i]+bx[j]==num+1)
  77. {
  78. px=i;
  79. py=j;
  80. break;
  81. }
  82. }
  83. else
  84. {
  85. if(ax[i]+bx[j]==num)
  86. {
  87. px=i;
  88. py=j;
  89. break;
  90. }
  91. }
  92. }
  93. }
  94. if(px==-1||py==-1)
  95. {
  96. cout<<"NO"<<endl;
  97. }
  98. else
  99. {
  100. cout<<"YES"<<endl;
  101. cout<<px+1<<" "<<py+1<<endl;
  102. }
  103. return 0;
  104. }

  

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

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

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

  2. Codeforces Round #363 (Div. 2)

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

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

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

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

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

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

  6. 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] ...

  7. Codeforces Round #363 (Div. 2)A-D

    699A 题意:在一根数轴上有n个东西以相同的速率1m/s在运动,给出他们的坐标以及运动方向,问最快发生的碰撞在什么时候 思路:遍历一遍坐标,看那两个相邻的可能相撞,更新ans #include< ...

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

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

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

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

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

随机推荐

  1. Nested loops、Hash join、Sort merge join(三种连接类型原理、使用要点)

    nested loop 嵌套循环(原理):oracle从较小结果集(驱动表.也可以被称为outer)中读取一行,然后和较大结果集(被侦查表,也可以叫做inner)中的所有数据逐条进行比较(也是等值连接 ...

  2. CentOS6 下Samba服务器的安装与配置

    原地址:http://www.cnblogs.com/mchina/archive/2012/12/18/2816717.html 一.简介 Samba是一个能让Linux系统应用Microsoft网 ...

  3. python中http请求中添加cookie支持

    python3中构造http的Request需要用到urllib.request. 有时会用到cookie. 比如在访问网站首页得到cookie,通过下面代码添加cookie:      #insta ...

  4. 如何在windows 2003(虚拟主机)上面部署MVC3

    相信有很多朋友和我一样遇到了这个问题,网上大牛说的都不是很清楚,关于这个问题我详细的跟进一下 这个问题呢大致分为两种情况 一.有服务器的控制权限,这个就简单很多, 1.安装mvc3支持组件2.如果可以 ...

  5. altium designer 中的top/bottom solder和top/bottom paste mask

    转载请注明出处:http://blog.csdn.net/qq_26093511/article/details/51751936 1.top solder为助焊层,说白一点就是说,有这个层的地方就没 ...

  6. [原创] 新人分享--ORA-01012:not logged on的解决办法 [复制链接]

    转自:http://f.dataguru.cn/thread-82530-1-1.html

  7. Delegate Action<T in> Func<T in,out Tresult> Predicate<T>

    action<T> 和  func<T> 都是delegate的简写形式,其中T为可以接受的参数类型 action<T> 指那些只有输入参数,没有返回值 Deleg ...

  8. [Uva10641]Barisal Stadium(区间dp)

    题意:按照顺时针给出操场的周边点,然后给出周围可以建设照明灯的位置,以及在该位置建设照明灯的代价,照明灯照射的范围与操场的边界相切,现在要求一个最小的花费,要求操场的所有边都被照射到. 解题关键:预处 ...

  9. [hdu4662]MU Puzzle(找规律)

    题意:给你一个串MI,按照三种规则1:M后面的部分加倍 2:III->U 3:删去连续的两个UU.看看能否变为给定的串 解题关键:将所有的U转化为I,发现 t+k*6=2^i -> =2^ ...

  10. base64 数据加密

    1.新建一个base64.js文件 添加下面的代码 /* Copyright (C) 1999 Masanao Izumo <iz@onicos.co.jp> * Version: 1.0 ...