HDU5926-Mr. Frog’s Game
来源:互联网 发布:中铁四局网络采购平台 编辑:程序博客网 时间:2024/05/18 11:11
Mr. Frog’s Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1168 Accepted Submission(s): 582
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东北地区大学生程序设计竞赛 - 重现赛
Recommend
wange2014
题意:给你一个n*m的矩阵,相同的格子只有相连或者在同一边上的才能消掉,问图中是否有能消掉的格子。
解题思路:就判断边上和内部就好
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <string>#include <math.h>#include <time.h>#include <algorithm>#include <vector>#include <stack>#include <queue>#include <map>#include <set>using namespace std;const int INF = 0x3f3f3f3f;#define LL long longint mp[50][50];int n, m;int main(){int t,cas=0;scanf("%d", &t);while (t--){scanf("%d%d", &n, &m);for(int i=0;i<n;i++)for (int j = 0;j < n;j++)scanf("%d", &mp[i][j]);int flag = 0;for(int i=0;i<n;i++)for (int j = i + 1;j < n;j++)if (mp[i][0] == mp[j][0] || mp[i][m - 1] == mp[j][m - 1]) flag = 1;for (int i = 0;i<m;i++)for (int j = i + 1;j < m;j++)if (mp[0][i] == mp[0][j] || mp[n-1][i] == mp[n-1][j]) flag = 1;for(int i=1;i<n-1;i++)for (int j = 1;j < m - 1;j++)if (mp[i][j] == mp[i - 1][j] || mp[i][j] == mp[i + 1][j]|| mp[i][j] == mp[i][j - 1] || mp[i][j] == mp[i][j + 1]) flag = 1;printf("Case #%d: ", ++cas);if (flag) printf("Yes\n");else printf("No\n");}return 0;}
阅读全文
0 0
- HDU5926-Mr. Frog’s Game
- hdu5926 Mr. Frog’s Game 小模拟 国庆咸鱼
- 【HDU5926 2016CCPC东北地区大学生程序设计竞赛 - 重现赛 E】【水题】Mr. Frog’s Game 连连看
- hdu 5926/ Mr. Frog’s Game
- HDU 5926 Mr. Frog’s Game
- 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东北地区大学生程序设计竞赛)
- hdu 5926 Mr. Frog’s Game 2016CCPC东北地区大学生程序设计竞赛E题(模拟)
- (HDU 5926)Mr. Frog’s Game 水题 <2016CCPC东北地区大学生程序设计竞赛 - 重现赛 >
- HDU 5924 Mr. Frog’s Problem【规律】
- git的缺点(1) -- 不能add空文件夹
- JustOj 1256: 成绩排名 (结构体排序)
- express-1-helloworld
- Leetcode 326 Power of Three
- 仿金融APP收益曲线图
- HDU5926-Mr. Frog’s Game
- Python笔记3-python基础2
- 达林顿电路分析
- 针对移动机器人的人体目标检测和跟踪系统的实现
- Leetcode 338 Counting Bits
- android注解的基本原理和使用
- C++中函数重载
- Leetcode 342 Power of Four
- 测试TensorFlow Object Detection API