博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Mr. Frog’s Game
阅读量:6284 次
发布时间:2019-06-22

本文共 3436 字,大约阅读时间需要 11 分钟。

Mr. Frog’s Game

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 312    Accepted Submission(s): 209

Problem Description
One day, Mr. Frog is playing Link Game (Lian Lian Kan in Chinese).
In this game, if you can draw at most three horizontal or vertical head-and-tail-connected lines over the empty grids(the lines can be out of the whole board) to connect two non-empty grids with the same symbol or the two non-empty grids with the same symbol are adjacent, then you can change these two grids into empty and get several more seconds to continue the game.
Now, Mr. Frog starts a new game (that means there is no empty grid in the board). If there are no pair of grids that can be removed together,Mr. Frog will say ”I’m angry” and criticize you.
Mr. Frog is battle-scarred and has seen many things, so he can check the board in a very short time, maybe one second. As a Hong Kong Journalist, what you should do is to check the board more quickly than him, and then you can get out of the room before Mr. Frog being angry.
 

 

Input
The first line contains only one integer T (
T500 ), which indicates the number of test cases.
For each test case, the first line contains two integers n and m (1n,m30 ).
In the next n lines, each line contains m integers,  j-th number in the i-th line means the symbol on the grid(the same number means the same symbol on the grid).
 

 

Output
For each test case, there should be one line in the output.
You should output “Case #x: y”,where x is the case number(starting from 1), and y is a string representing the answer of the question. If there are at least one pair of grids that can be removed together, the y is “Yes”(without quote), else y is “No”.
 

 

Sample Input
2 3 3 1 2 1 2 1 2 1 2 1 3 3 1 2 3 2 1 2 3 2 1
 

 

Sample Output
Case #1: Yes Case #2: No
Hint
first sample can be explained as below.
 

 

Source
 

 

Recommend
wange2014   |   We have carefully selected several similar problems for you:            
/*这个题可以搜索,但是30*30完全可以暴力*/#include
using namespace std;int pa[32][32];int main(){ //freopen("C:\\Users\\acer\\Desktop\\in.txt","r",stdin); int T,nl = 0,N,M,i,j,pl; scanf("%d",&T); while(T--) { pl = 0; scanf("%d%d",&N,&M); for(i = 1 ; i <= N; i++) for(j = 1 ; j <= M; j++) scanf("%d",&pa[i][j]); for(i = 1 ; i < M ; i++)///判断边上是不是有相同的 { for(j = i + 1 ; j <= M ; j++) if((pa[1][i] == pa[1][j]) || (pa[N][i] == pa[N][j])) pl = 1; if(pl) break; } if(!pl) { for(i = 1 ; i < N ; i++)///判断是不是有相连的有相同的 { for(j = i + 1 ; j <= N ; j++) if((pa[i][1] == pa[j][1]) || (pa[i][M] == pa[j][M])) pl = 1; if(pl) break; } if(!pl) { for(i = 1 ; i <= N ; i++)///判断是不是有相连的有相同的 { for(j = 1 ; j <= M ; j++) { if(i!= N && pa[i][j] == pa[i + 1][j]) pl = 1; if(j!= M && pa[i][j] == pa[i][j + 1]) pl = 1; } if(pl) break; } } } if(pl) printf("Case #%d: Yes\n",++nl); else printf("Case #%d: No\n",++nl); } return 0;}

 

转载于:https://www.cnblogs.com/wuwangchuxin0924/p/6005329.html

你可能感兴趣的文章
3.31
查看>>
类对象定义 二
查看>>
收费视频网站Netflix:用户到底想要“点”什么?
查看>>
MacOS High Sierra 12 13系统转dmg格式
查看>>
关于再次查看已做的多选题状态逻辑问题
查看>>
动态下拉菜单,非hover
查看>>
政府安全资讯精选 2017年第十六期 工信部发布关于规范互联网信息服务使用域名的通知;俄罗斯拟建立备用DNS;Google打击安卓应用在未经同意情况下收集个人信...
查看>>
简单易懂的谈谈 javascript 中的继承
查看>>
iOS汇编基础(四)指针和macho文件
查看>>
Laravel 技巧锦集
查看>>
Android 使用 ViewPager+RecyclerView+SmartRefreshLayout 实现顶部图片下拉视差效果
查看>>
Flutter之基础Widget
查看>>
写给0-3岁产品经理的12封信(第08篇)——产品运营能力
查看>>
ArcGIS Engine 符号自动化配置工具实现
查看>>
小程序 · 跳转带参数写法,兼容url的出错
查看>>
flutter error
查看>>
Flask框架从入门到精通之模型数据库配置(十一)
查看>>
10年重新出发
查看>>
2019年-年终总结
查看>>
聊聊elasticsearch的RoutingService
查看>>