Link: CodeForces-566-B
Description:
You have a given picture with size w×h. Determine if the given picture has a single "+" shape or not. A "+" shape is described below:

A "+" shape has one center nonempty cell.
There should be some (at least one) consecutive non-empty cells in each direction (left, right, up, down) from the center. In other words, there should be a ray in each direction.
All other cells are empty.
Find out if the given picture has single "+" shape.

Input
The first line contains two integers h and w (1≤h, w≤500) — the height and width of the picture.

The i-th of the next h lines contains string si of length w consisting "." and "*" where "." denotes the empty space and "*" denotes the non-empty space.

Output
If the given picture satisfies all conditions, print "YES". Otherwise, print "NO".

You can output each letter in any case (upper or lower).

Examples
input

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

output
YES

input

3 5
..*..
****.
.*...

output
NO

input

7 7
.......
...*...
..****.
...*...
...*...
.......
.*.....

output
NO

input

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

output
NO

input

3 7
.*...*.
***.***
.*...*.

output
NO

input

5 10
..........
..*.......
.*.******.
..*.......
..........

output
NO

Note

In the first example, the given picture contains one "+".
In the second example, two vertical branches are located in a different column.
In the third example, there is a dot outside of the shape.
In the fourth example, the width of the two vertical branches is 2.
In the fifth example, there are two shapes.
In the sixth example, there is an empty space inside of the shape.

Intentional analysis:
My way is find the center * of the "+".And turn all of the '*' in "+" to '.'.And if there is still has '*' in the map.Should print "NO",if not,print "YES".But there is a special situation,there has no '*' in the map,we'd better make a flag number to satisfy this.

Click to see Chinese Intentional analysis 我的方法就是找到“+”最中间的‘\*’。然后把“+”中的'\*'全部变成‘.’。然后再看图里面有没有‘\*’,如果有就输出“NO”,没有就输出“YES”。但是还有一种情况就是图里面没有'\*',这个特殊处理一下就行。

Code:

#include <bits/stdc++.h
using namespace std;
const int maxn = 550;
char      m[maxn][maxn];
int       x[maxn];
void find(int x, int y, int z)
{
    if (z == 0)
    {
        while (m[x][y] == '*')
        {
            m[x][y] = '.';
            y++;
        }
    }
    if (z == 1)
    {
        while (m[x][y] == '*')
        {
            m[x][y] = '.';
            x++;
        }
    }
    if (z == 2)
    {
        while (m[x][y] == '*')
        {
            m[x][y] = '.';
            y--;
        }
    }
    if (z == 3)
    {
        while (m[x][y] == '*')
        {
            m[x][y] = '.';
            x--;
        }
    }
}
int main()
{
    int  w, h;
    bool flag = 0;
    cin  w  h;
    for (int i = 0; i < w; i++)
        for (int j = 0; j < h; j++)
            cin  m[i][j];
    for (int i = 0; i < w; i++)
    {
        for (int j = 0; j < h; j++)
        {
            if (m[i][j] == '*')
            {
                int mid = 0;
                if (m[i - 1][j] == '*')
                    mid++;
                if (m[i][j - 1] == '*')
                    mid++;
                if (m[i + 1][j] == '*')
                    mid++;
                if (m[i][j + 1] == '*')
                    mid++;
                if (mid == 4)
                {
                    for (int k = 0; k < 4; k++)
                    {
                        m[i][j] = '*';
                        find(i, j, k);
                        flag = 1;
                    }
                }
            }
            if (flag)
                break;
        }
        if (flag)
            break;
    }
    bool f = 0;
    for (int i = 0; i < w; i++)
        for (int j = 0; j < h; j++)
        {
            if (m[i][j] == '*')
                f = 1;
        }
    if (!f && flag)
        puts("YES");
    else
        puts("NO");
    return 0;
}