日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

One Bomb

發(fā)布時間:2023/12/19 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 One Bomb 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
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 YES
1 2 input 3 3
..*
.*.
*.. output NO input 6 5
..*..
..*..
*****
..*..
..*..
..*.. output YES
3 3

分析:分別記錄行和列的墻的個數(shù),然后遍歷一遍點即可;

代碼:

#include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include <algorithm> #include <climits> #include <cstring> #include <string> #include <set> #include <map> #include <queue> #include <stack> #include <vector> #include <list> #include <ext/rope> #define rep(i,m,n) for(i=m;i<=n;i++) #define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++) #define vi vector<int> #define pii pair<int,int> #define mod 1000000007 #define inf 0x3f3f3f3f #define pb push_back #define mp make_pair #define fi first #define se second #define ll long long #define pi acos(-1.0) const int maxn=1e3+10; const int dis[4][2]={{0,1},{-1,0},{0,-1},{1,0}}; using namespace std; using namespace __gnu_cxx; ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);} ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;} int n,m,cnt,r[maxn],c[maxn]; char a[maxn][maxn]; int main() {int i,j,k,t;scanf("%d%d",&n,&m);rep(i,0,n-1)scanf("%s",a[i]);rep(i,0,n-1)rep(j,0,m-1)if(a[i][j]=='*')r[i]++,c[j]++,cnt++;rep(i,0,n-1)rep(j,0,m-1)if(r[i]+c[j]-(a[i][j]=='*')==cnt)return 0*printf("YES\n%d %d\n",i+1,j+1);puts("NO");//system ("pause");return 0; }

?

轉(zhuǎn)載于:https://www.cnblogs.com/dyzll/p/5687084.html

總結(jié)

以上是生活随笔為你收集整理的One Bomb的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。