[原创]华中农业大学第五届程序设计大赛 J Color Circle
[原创]华中农业大学第五届程序设计大赛 J Color Circle
2017-05-26 22:41:01 Tabris_ 阅读数:317
博客爬取于2020-06-14 22:40:28
以下为正文
版权声明:本文为Tabris原创文章,未经博主允许不得私自转载。
https://blog.csdn.net/qq_33184171/article/details/72774870
题目连接:http://acm.hzau.edu.cn/problem.php?id=1208
——————————————————————
1208: Color Circle
Time Limit: 1 Sec Memory Limit: 1280 MB
Submit: 344 Solved: 104
[Submit][Status][Web Board]
Description
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:
Every point is different.
k >= 4
All points belong to the same color.
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.
Input
There are multiply test cases.
In each case, the first line are two integers n and m, the 2nd ~ n+1th lines is the given n*m matrix. Input m characters in per line.
Output
Output your answer as “Yes” or ”No” in one line for each case.
Sample Input
3 3
AAA
ABA
AAA
Sample Output
Yes
————————————————————————————
题目大意:
问你能不能找到一个由一种颜色构成的圈
有求,
1.至少有4个点
2.所有点首尾相接构成一个圈
3.颜色相同
4.点是不同的
解题思路:
由于图很小,所以暴力搜就好了,
附本题代码
——————————————————————————
1 | # include <bits/stdc++.h> |