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

output
YES1 2

input
3 3..*.*.*..

output
NO

input
6 5..*....*..*****..*....*....*..

output
YES3 3

题意:你有一个炸弹,可以放在任意位置并炸掉该位置所在的行和列上的墙“*”,求一颗炸弹是否能炸掉所有的墙。

我们可以将每行和每列的墙数分别存入数组x[]和y[]。每当a[i][j]的位置是"*"时,x[i]++,y[j]++;最后再将x[i]+y[j]与总墙数sum比较。

注意:当炸弹所在点为“*”时,需x[i]+y[j]-1;

附AC代码:

 1 #include<iostream>
 2 #include<cstring>
 3
 4 using namespace std;
 5
 6 int N,M,ans;
 7 int a[1002][1002],x[1002],y[1002];
 8 char s[200010];
 9
10 void process(){
11     scanf("%d %d",&N,&M);
12     int cnt = 0;
13     for(int i=1; i<=N; i++){
14         scanf("%s",s);
15         for(int j=1; j<=M; j++){
16             if(s[j-1] == '*'){
17                 x[i]++;
18                 y[j]++;
19                 cnt++;
20                 a[i][j] = 1;
21             }
22         }
23     }
24     for(int i=1; i<=N; i++){
25         for(int j=1; j<=M; j++){
26             int t;
27             t = x[i]+y[j];
28             if(a[i][j] == 1) t--;//重复一个
29             if(t == cnt){
30                 printf("YES\n%d %d\n",i,j);
31                 return;
32             }
33         }
34     }
35     printf("NO\n");
36 }
37
38 int main(){
39     process();
40     return 0;
41 }

转载于:https://www.cnblogs.com/Kiven5197/p/5687391.html

B. One Bomb (#363 Div.2)相关推荐

  1. CodeForces 698A - Vacations (Codeforces Round #363 (Div. 2))

    要么去体育馆,要么去比赛,要么闲在家里 给出每一天体育馆和比赛的有无情况,要求连续两天不能去同一个地方 问最少闲几天 DP方程很容易看出 dp(第i天能去的地方) = min(dp(第i-1天的三种情 ...

  2. python第七十九天--第十四周作业

    1 <!DOCTYPE html> 2 <html lang="en"> 3 4 <head> 5 <meta charset=" ...

  3. ExtJS6.0扩展日期选择控件为也可以选择时间

    PS:ExtJS自带的日期选择控件只能够选择日期,但是现在的需求需要精确到秒,所以在网上搜索了一些例子(大部分是4.0的)作为参考,然后改出了6.0可用的一个日期时间选择控件. 1.找到extjs6. ...

  4. Bootstrap 快速人门案例——前端最火的插件

    今天,我给小白们分享一下比较流行的Bootstrap框架,它在工作中得到许多公司的青睐,因此对于升职和加薪很重要.同时,我们可以快速完成开发任务,减少发开周期,有不对的地方望大家指正. 如果你想走的更 ...

  5. 原生js实现问卷调查

    1 <div class="swiper-container swiper-no-swiping"> 2 <div class="swiper-wrap ...

  6. 项目一~美食达人图册

    浏览器截图部分: 1 reset.css: 2 @charset "utf-8"; 3 /*=========================Reset_start======== ...

  7. 电影主题HTM5网页设计作业成品——爱影评在线电影(10页面)使用dreamweaver制作采用DIV+CSS进行布局

    HTML实例网页代码, 本实例适合于初学HTML的同学.该实例里面有设置了css的样式设置,有div的样式格局,这个实例比较全面,有助于同学的学习,本文将介绍如何通过从头开始设计个人网站并将其转换为代 ...

  8. CSAPP——Lab2——Bomb Lab

    本篇博客是<深入理解计算机系统>实验记录的第二篇,也是非常有名的炸弹实验.首先吐槽一下学校的这个实验代码不更新的问题,教材和上课讲授的均是x86-64位汇编语言,结果实验给的还是第二版配套 ...

  9. 文章内容中表格宽度超过内容区自动在外层添加div和样式并在电脑端可滑动浏览

    HTML部分: <div class="newscon" id="conbox"> <table> <tbody><t ...

最新文章

  1. java string.indexof(string)_Java StringBuffer indexOf()方法
  2. apache开启 gzip 压缩
  3. leetcode valid number
  4. MongoDB基本概念学习 - 文档
  5. 网络day02-设备配置远程登录
  6. @hdu - 6372@ sacul
  7. C++设计模式-Bridge桥接模式
  8. Dalvik 堆内存管理与回收
  9. 八.激光SLAM框架学习之LeGO-LOAM框架---框架介绍和运行演示
  10. python long转int_将 python long/int转换为固定大小的字节数组_others_酷徒编程知识库...
  11. 高斯模型matlab程序代码,我找到的高斯混合模型的代码
  12. Android shape自定义形状,设置渐变色
  13. 2020《互联网周刊》年度评选结果揭晓, Smartbi获三项行业大奖
  14. Objective-C的算术表达式 .
  15. IDEA-Translation插件更新TKK失败
  16. stm32f407zgt6与stm32f407vet6的通用io口差别
  17. 决策模型(二):风险决策法
  18. 怎么退出python
  19. SpringBoot 必知必会的19个常用注解
  20. Python调用海康SDK进行车牌识别(动态链接库的方法—不通过swig)

热门文章

  1. *由易到难的讲解动态规划(精)
  2. 【Codeforces - 632C】The Smallest String Concatenation (对string巧妙排序)
  3. 51nod 1091 重叠的线段(贪心)
  4. 《TCP/IP详解》学习笔记(三):IP协议、ARP协议
  5. 4.Model Validation
  6. 采油工计算机试题库,数字化采油工试题库.doc
  7. html 类型转换,JavaScript怎么进行类型转换?
  8. .NET短信接口验证
  9. SSH项目中根据Hibernate的映射文件生成数据库表的方案:
  10. Struts1.x和Struts2.0的Action的区别