当前位置: 代码迷 >> 综合 >> Color Circle
  详细解决方案

Color Circle

热度:54   发布时间:2024-01-08 23:46:31.0

题目描述
There are colorful flowers in the parterre in front of the door of college and form many beautiful patterns. Now, you want to find a circle consist of flowers with same color. What should be done ?

Assuming the flowers arranged as matrix in parterre, indicated by a N*M matrix. Every point in the matrix indicates the color of a flower. We use the same uppercase letter to represent the same kind of color. We think a sequence of points d1, d2, … dk makes up a circle while:

1. Every point is different.2. k >= 43. All points belong to the same color.4. For 1 <= i <= k-1, di is adjacent to di+1 and dk is adjacent to d1. ( Point x is adjacent to Point y while they have the common edge).N, M <= 50. Judge if there is a circle in the given matrix. 

输入描述
There are multiply test cases.

In each case, the first line are two integers n and m, the 2nd ~ n

  相关解决方案