P24954 [AtCoder] [ARC031B] Land Reclamation
普及
题目描述

Problem Description

In a certain island country, there are several islands. Recently, a land reclamation plan has been drafted, but the specific area to be reclaimed has not been decided yet. Ideally, they would like to connect the islands by reclaiming land to form a single island, but they cannot reclaim too much land. Given a 10x10 map of the island country, determine if it is possible to form a single island by reclaiming just one square of sea. An island is defined as a region where the land squares are connected vertically or horizontally.

Input Format

The input is given from the standard input in the following format:

$ A_{1,1} $$ A_{1,2} $...$ A_{1,10} $ $ A_{2,1} $$ A_{2,2} $...$ A_{2,10} $ : $ A_{10,1} $$ A_{10,2} $...$ A_{10,10} $

  • The map of the island country is given over 10 lines.
  • Each line consists of 10 characters, where o represents land and x represents sea.
  • It is guaranteed that there is at least one land square.
  • It is guaranteed that there is at least one sea square.

Output Format

Output YES if the entire area can be made into a single island by converting one sea square to land, otherwise output NO. Ensure a newline at the end of the output. Note that if it is already a single island, output YES.

Sample Input and Output

Sample Input #1

xxxxxxxxxx
xoooooooxx
xxoooooxxx
xxxoooxxxx
xxxxoxxxxx
xxxxxxxxxx
xxxxoxxxxx
xxxoooxxxx
xxoooooxxx
xxxxxxxxxx

Sample Output #1

YES

Sample Input #2

xxxxxxxxxx
xoooooooxx
xxoooooxxx
xxxoooxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxoooxxxx
xxoooooxxx
xxxxxxxxxx

Sample Output #2

NO

Sample Input #3

xxxxoxxxxx
xxxxoxxxxx
xxxxoxxxxx
xxxxoxxxxx
ooooxooooo
xxxxoxxxxx
xxxxoxxxxx
xxxxoxxxxx
xxxxoxxxxx
xxxxoxxxxx

Sample Output #3

YES

Notes/Hints

None

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
xxxxxxxxxx xoooooooxx xxoooooxxx xxxoooxxxx xxxxoxxxxx xxxxxxxxxx xxxxoxxxxx xxxoooxxxx xxoooooxxx xxxxxxxxxx
样例输出
YES