Mr. Frog’s Game(模拟连连看)
Description
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
For each test case, the first line contains two integers n and m ($1 \leq n,m \leq 30$).
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
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
Sample Output
Hint
first sample can be explained as below.
题目意思:这是一个连连看游戏,只要矩阵内部有两个相同图案相邻或者外围(四条最外边)上只少有两个相同的图案,就可以进行一次消去,问能否进行一次消去。
解题思路:大致分为两种情况:1矩阵内部有相邻的图案,2矩阵外围上至少有两个相同的图案。直接暴力遍历这个矩阵即可。
#include<stdio.h>
#include<string.h>
int main()
{
int t,i,j,n,m,flag,count=;
int a[][];
scanf("%d",&t);
while(t--)
{
flag=; memset(a,,sizeof(a));
scanf("%d%d",&n,&m);
for(i=; i<=n; i++)
{
for(j=; j<=m; j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=; i<m; i++)
{
for(j=i+; j<=m; j++)
{
if(a[][i]==a[][j]||a[n][i]==a[n][j])
{
flag=;
}
}
if(flag==)
{
break;
}
}
for(i=; i<n; i++)
{
for(j=i+; j<=n; j++)
{
if(a[i][]==a[j][]||a[i][m]==a[j][m])
{
flag=;
}
}
if(flag==)
{
break;
}
}
for(i=; i<=n; i++)
{
for(j=; j<=m; j++)
{
if(i!=n&&a[i][j]==a[i+][j])
{
flag=;
}
if(j!=m&&a[i][j]==a[i][j+])
{
flag=;
}
}
if(flag==)
{
break;
}
}
if(flag==)
{
printf("Case #%d: Yes\n",count);
count++;
}
else
{
printf("Case #%d: No\n",count);
count++;
}
}
return ;
}
Mr. Frog’s Game(模拟连连看)的更多相关文章
- HDU 5926 Mr. Frog's Game 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
Mr. Frog's Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- HDU 5924 Mr. Frog’s Problem 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
Mr. Frog's Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- Mr. Frog’s Game
Mr. Frog’s Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- 【CF625E】Frog Fights(模拟)
[CF625E]Frog Fights(模拟) 题面 CF 洛谷 翻译: 有\(n\)只青蛙在一个被分为了\(m\)等分的圆上,对于每份顺时针依次标号. 初始时每只青蛙所在的位置是\(p_i\),速度 ...
- HDU5926 Mr. Frog’s Game
/* HDU5926 Mr. Frog’s Game http://acm.hdu.edu.cn/showproblem.php?pid=5926 杂题水题 * */ #include <cst ...
- HDU5924 Mr. Frog’s Problem
/* HDU5924 Mr. Frog’s Problem http://acm.hdu.edu.cn/showproblem.php?pid=5924 数论 * */ #include <cs ...
- Codeforces Round #342 (Div. 2) E. Frog Fights set 模拟
E. Frog Fights 题目连接: http://www.codeforces.com/contest/625/problem/E Description stap Bender recentl ...
- hdu-5929 Basic Data Structure(双端队列+模拟)
题目链接: Basic Data Structure Time Limit: 7000/3500 MS (Java/Others) Memory Limit: 65536/65536 K (Ja ...
- HDU 5918 KMP/模拟
Sequence I Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
随机推荐
- Docker镜像浅谈
先抛出几个我在学习过程中产生的几个问题. 1. 容器镜像是什么, 和装系统时的镜像有什么关系? 2. 容器镜像的作用是什么? 3. 不同版本的ubuntu镜像有什么区别, 比如说 ubuntu:18. ...
- 基于LSB的图像数字水印实验
1. 实验类别 设计型实验:MATLAB设计并实现基于LSB的图像数字水印算法. 2. 实验目的 了解信息隐藏中最常用的LSB算法的特点,掌握LSB算法原理,设计并实现一种基于图像的LSB隐藏算法. ...
- 执行SQL查询导致磁盘耗尽故障演示
a fellow in IMG wechat group 2 met an error about running out of disk space when using MySQL ...
- git获取步骤
$ git init $ git config --global user.name "[name]" $ git config --global user.email [emai ...
- linux ping命令实践
ping 解析 Linux系统的ping命令是常用的网络命令,它通常用来检测与目标主机的连通性,经常说"ping以下机器,看是否开着,不能打开网页时候,可以ping ...
- html+css3 实现各种loading效果
效果见下图 代码: 建议直接去本人github上浏览代码 https://github.com/wuliqiangqiang/loading <!DOCTYPE html> <htm ...
- 导航栏NavigationBar的按钮设置
有时候在自定义navigationBar的左右按钮的时候,button的图片会显得很大,个人感觉原因有以下几种情况: 1.使用的是UIButton直接加在navigationBar上面 2.自定义了一 ...
- Mysql 关于处理NULL值的相关函数和操作符
操作符 <=> NULL-safe equal. This operator performs an equality comparison like the = operator, bu ...
- 支付宝H5、APP支付服务端的区别(php)
php支付宝H5和APP支付1.准备工作需要前往 蚂蚁金服开放平台申请https://openhome.alipay.com/developmentDocument.htm 2.大致流程1.用户添加商 ...
- 面试:Hbase和Hive的区别
区别: 1. Hive是一个构建在Hadoop基础设施之上的数据仓库,通过HQL查询存放在HDFS上的数据,不能交互查询.HBase是一种Key/Value系统,它运行在HDFS之上,可以交互查询. ...