hdu5926 Mr. Frog’s Game 小模拟 国庆咸鱼
来源:互联网 发布:淘宝上代写文章靠谱吗 编辑:程序博客网 时间:2024/05/04 01:03
Mr. Frog’s Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 35 Accepted Submission(s): 28
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.
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 (T≤500 ), which indicates the number of test cases.
For each test case, the first line contains two integers n and m (1≤n,m≤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).
For each test case, the first line contains two integers n and m (
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”.
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
23 31 2 12 1 21 2 13 31 2 32 1 23 2 1
Sample Output
Case #1: YesCase #2: NoHintfirst sample can be explained as below.
Source
2016CCPC东北地区大学生程序设计竞赛 - 重现赛
很不科学的连连看。。。按照我的认知来说一般的连连看不是每个边界都可以连在一起吗???
然而这个是只有相邻的两个或者是处在同一条边上的相同数字才能连连消掉。。
反正降低难度了吧。。。一定有很多人按照自己玩连连看的习惯wa了吧
下面代码:
#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <algorithm>#include <set>#include <map>#include <vector>#include <queue>#include <cmath>using namespace std;const int maxn=40;int save[maxn][maxn];bool judge[1000];int main(){int t;scanf("%d",&t);int rnd=1;while(t--){int n,m,i,j;scanf("%d%d",&n,&m);bool flag=false;for(i=1;i<=n;i++){for(j=1;j<=m;j++){scanf("%d",&save[i][j]);if(i>1){if(save[i-1][j]==save[i][j]){flag=true;}}if(j>1){if(save[i][j-1]==save[i][j]){flag=true;}}}}if(!flag){memset(judge,false,sizeof(judge));for(i=1;i<=n;i++){if(!judge[save[i][1]]){judge[save[i][1]]=true;}else{flag=true;break;}}memset(judge,false,sizeof(judge));for(i=1;i<=n;i++){if(!judge[save[i][m]]){judge[save[i][m]]=true;}else{flag=true;break;}}memset(judge,false,sizeof(judge));for(i=1;i<=m;i++){if(!judge[save[1][i]]){judge[save[1][i]]=true;}else{flag=true;break;}}memset(judge,false,sizeof(judge));for(i=1;i<=m;i++){if(!judge[save[n][i]]){judge[save[n][i]]=true;}else{flag=true;break;}}}if(flag){printf("Case #%d: Yes\n",rnd);}else{printf("Case #%d: No\n",rnd);}rnd++;} return 0;}
0 0
- hdu5926 Mr. Frog’s Game 小模拟 国庆咸鱼
- HDU5926-Mr. Frog’s Game
- hdu5924 Mr. Frog’s Problem 打表找规律 国庆咸鱼
- 【HDU5926 2016CCPC东北地区大学生程序设计竞赛 - 重现赛 E】【水题】Mr. Frog’s Game 连连看
- hdu 5926/ Mr. Frog’s Game
- HDU 5926 Mr. Frog’s Game
- HDU 5926 Mr. Frog's Game 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
- hdu 5926 Mr. Frog’s Game 2016CCPC东北地区大学生程序设计竞赛E题(模拟)
- 2016CCPC东北地区大学生程序设计竞赛-Mr. Frog’s Game
- HDU 5926 Mr. Frog’s Game (水)
- HDU5924-Mr. Frog’s Problem
- Mr. Frog’s Problem C
- Mr. Frog’s Problem HDU
- hdu5926Mr. Frog’s Game
- [2016CCPC东北地区大学生程序设计竞赛]Mr. Frog’s Game 遍历
- HDU Mr. Frog’s Game 2016CCPC东北地区大学生程序设计竞赛 - 重现赛
- Mr. Frog’s Game(弱校联盟十一专场(连连看))
- (HDU 5926)Mr. Frog’s Game 水题 <2016CCPC东北地区大学生程序设计竞赛 - 重现赛 >
- 图像缩放之双线性内插值法
- AsyncTask异步任务
- web数据挖掘的前期数据获取步骤
- EncodingFilter 全站编码过滤器 get请求中文编码过滤
- 关于位拼运算符的应用
- hdu5926 Mr. Frog’s Game 小模拟 国庆咸鱼
- 远程访问 PowerShell
- 导入项目提示Invalid project description
- CodeForces Gym Trainings Season 3 Episode 5 A题
- 网络流之最大流-Ford-Fullkerson算法 DFS && BFS
- 使用数组构建线性表的顺序表数据结构
- execute(sql)三种执行方法的返回值表示的含义
- 先验概率、后验概率、似然函数
- 大型网站架构演进(分布式系统二)