HDU 5926 Mr. Frog's Game 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
来源:互联网 发布:淘宝官方客服电话400 编辑:程序博客网 时间:2024/04/30 06:58
Mr. Frog’s Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 277 Accepted Submission(s): 192
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 | We have carefully selected several similar problems for you: 5932 5931 5930 5929 5928
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=5926
题目大意:
N*M(N,M<=30)的格子,求连连看第一步是否能连。
题目思路:
【模拟】
+1s 直接枚举相邻的,最外层的能否跨接即可。
////by coolxxx//#include<bits/stdc++.h>#include<iostream>#include<algorithm>#include<string>#include<iomanip>#include<map>#include<stack>#include<queue>#include<set>#include<bitset>#include<memory.h>#include<time.h>#include<stdio.h>#include<stdlib.h>#include<string.h>//#include<stdbool.h>#include<math.h>#pragma comment(linker,"/STACK:1024000000,1024000000")#define min(a,b) ((a)<(b)?(a):(b))#define max(a,b) ((a)>(b)?(a):(b))#define abs(a) ((a)>0?(a):(-(a)))#define lowbit(a) (a&(-a))#define sqr(a) ((a)*(a))#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))#define mem(a,b) memset(a,b,sizeof(a))#define eps (1e-10)#define J 10000#define mod 1000000007#define MAX 0x7f7f7f7f#define PI 3.14159265358979323#define N 34using namespace std;typedef long long LL;double anss;LL aans;int cas,cass;int n,m,lll,ans;int a[N][N];int dx[]={-1,1,0,0};int dy[]={0,0,-1,1};bool judge(){int i,j,k;for(i=2;i<n;i++)for(j=2;j<m;j++)for(k=0;k<4;k++)if(a[i][j]==a[i+dx[k]][j+dy[k]])return 1;for(i=1;i<n;i++)for(j=i+1;j<=n;j++)if(a[1][i]==a[1][j] || a[n][i]==a[n][j])return 1;for(i=1;i<m;i++)for(j=i+1;j<=m;j++)if(a[i][1]==a[j][1] || a[i][m]==a[j][m])return 1;return 0;}int main(){#ifndef ONLINE_JUDGEW//freopen("1.txt","r",stdin);//freopen("2.txt","w",stdout);#endifint i,j,k;int x,y,z;//init();//for(scanf("%d",&cass);cass;cass--)for(scanf("%d",&cas),cass=1;cass<=cas;cass++)//while(~scanf("%s",s))//while(~scanf("%d%d",&n,&m)){printf("Case #%d: ",cass);scanf("%d%d",&n,&m);for(i=1;i<=n;i++)for(j=1;j<=m;j++)scanf("%d",&a[i][j]);if(judge())puts("Yes");else puts("No");}return 0;}/*////*/
0 0
- HDU 5926 Mr. Frog's Game 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
- hdu 5926 Mr. Frog’s Game 2016CCPC东北地区大学生程序设计竞赛E题(模拟)
- (HDU 5926)Mr. Frog’s Game 水题 <2016CCPC东北地区大学生程序设计竞赛 - 重现赛 >
- 2016CCPC东北地区大学生程序设计竞赛-Mr. Frog’s Game
- HDU Mr. Frog’s Game 2016CCPC东北地区大学生程序设计竞赛 - 重现赛
- HDU 5924 Mr. Frog’s Problem 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
- HDU 5926 Mr. Frog’s Game(连连看,暴力)——2016CCPC东北地区大学生程序设计竞赛 - 重现赛
- 2016CCPC东北地区大学生程序设计竞赛-Mr. Frog’s Problem
- [2016CCPC东北地区大学生程序设计竞赛]Mr. Frog’s Game 遍历
- HDU Mr. Frog’s Problem 2016CCPC东北地区大学生程序设计竞赛 - 重现赛
- hdu 5924 Mr. Frog’s Problem(2016CCPC东北地区大学生程序设计竞赛 C题,数学思维)
- (HDU 5924)Mr. Frog’s Problem 思维水题 <2016CCPC东北地区大学生程序设计竞赛 - 重现赛 >
- 【HDU5926 2016CCPC东北地区大学生程序设计竞赛 - 重现赛 E】【水题】Mr. Frog’s Game 连连看
- [2016CCPC东北地区大学生程序设计竞赛]Mr. Frog’s Problem 规律+打表
- 【HDU5924 2016CCPC东北地区大学生程序设计竞赛 - 重现赛 C】【水题】Mr. Frog’s Problem
- HDU 5922 Minimum’s Revenge 【模拟】(2016CCPC东北地区大学生程序设计竞赛)
- HDU 5924 Mr. Frog’s Problem(想看证明的来)——2016CCPC东北地区大学生程序设计竞赛 - 重现赛
- HDU 5929 Basic Data Structure 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
- Java 学生管理系统
- poj 3114 Countries in War
- C语言的int (*a)[10]等指针问题理解
- Linux USB 驱动开发实例(一) —— USB摄像头驱动实现源码分析
- 第八周项目3——顺序串算法
- HDU 5926 Mr. Frog's Game 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)
- Jquery获取json数据
- 第八周项目4-字符串加密
- Python-数字千分位的处理
- Android快速开发系列 10个常用工具类
- javascript cloneNode()方法
- 文章标题
- IE 8日期兼容问题
- 第八周项目3-顺序串算法