"About CF"
Title Link: CF 699B
Surface:
B. One bombtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
You are given a description of a depot. It is a rectangular checkered field ofn? x? M size. Each cell in a field can is 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'll wipe out all walls in the rowx and all walls in the column Y.
You were to determine if it was possible to wipe out all walls in the depot by placing and triggeringexactly one bomb. The bomb can is laid both in an empty cell or in a cell occupied by a wall.
Input
The first line contains the positive integers n andm (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 the them stands for cell (i,? J). If the symbol is equal to " ." and 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 fi RST line (without quotes).
Otherwise print "YES" (without quotes) in the first line and both integers in the second line-the coordinates of The cell at which the bomb should is laid. If There is multiple answers, print any of them.
Examplesinput
3 4.*.......*.
Output
YES1 2
Input
3 3..*.*.*.
Output
NO
Input
6 5..*....*. *****.. *....*....*..
Output
YES3 3
Test instructions
Ask if you can find a point in the diagram that causes the cross of the point to explode, eliminating all the walls (*) in the diagram.
Solving:
Before all kinds of trickery, not this fault, is that wrong. CF 2nd, or to simply want to directly count each row of stars, and then enumerate the location.
Code:
#include <iostream> #include <cstdio>using namespace Std;char mapp[1002][1002];int rowc[1002];int colc[ 1002];int n,m;int Check (int x,int y) {int res=0;res+=rowc[x];res+=colc[y];if (mapp[x][y]== ' * ') Res--;return res;} int main () {int x,y,cnt=0,tmp;scanf ("%d%d", &n,&m), for (int. i=1;i<=n;i++) {for (int j=1;j<=m;j++) {scanf (" %c ", &mapp[i][j]); if (mapp[i][j]== ' * ') {rowc[i]++;colc[j]++;cnt++;}}} BOOL flag=0; for (int i=1;i<=n;i++) {for (int j=1;j<=m;j++) {Tmp=check (i,j); if (tmp==cnt) {flag=1;x=i;y=j;break;}} if (flag) break;} if (flag) printf ("yes\n%d%d\n", X, y), elseprintf ("no\n"); return 0;}
"Play CF, learn algorithm--Two star" Codeforces 699b-one Bomb (Tips)