HDU5926 Mr. Frog’s Game

 1 /*
 2  HDU5926 Mr. Frog’s Game
 3  http://acm.hdu.edu.cn/showproblem.php?pid=5926
 4  杂题水题
 5  *
 6  */
 7 #include <cstdio>
 8 #include <algorithm>
 9 using namespace std;
10 const int Nmax=35;
11 int t,n,m;
12 int mapp[Nmax][Nmax];
13 int dx[]={0,1,-1,0,0};
14 int dy[]={0,0,0,1,-1};
15 int is()
16 {
17     for(int i=1;i<=m;i++)
18         for(int j=i+1;j<=m;j++)
19             if(mapp[1][i]==mapp[1][j] || mapp[n][i]==mapp[n][j])
20                 return 1;
21     for(int i=1;i<=n;i++)
22         for(int j=i+1;j<=n;j++)
23             if(mapp[i][1]==mapp[j][1] || mapp[i][m]==mapp[j][m])
24                 return 1;
25     for(int i=1;i<=n;i++)
26         for(int j=1;j<=m;j++)
27             for(int k=1;k<=4;k++)
28             {
29                 int nowx=i+dx[k],nowy=j+dy[k];
30                 if(nowx>=1 && nowx<=n && nowy>=1 && nowy<=n)
31                     if(mapp[nowx][nowy]==mapp[i][j])
32                         return 1;
33             }
34     return 0;
35 }
36
37 int main()
38 {
39     //freopen("in.in","r",stdin);
40     scanf("%d",&t);
41     for(int k=1;k<=t;k++)
42     {
43         printf("Case #%d: ",k);
44         scanf("%d%d",&n,&m);
45         for(int i=1;i<=n;i++)
46         {
47             for(int j=1;j<=m;j++)
48                 scanf("%d",&mapp[i][j]);
49         }
50         if(is())
51             printf("Yes\n");
52         else
53             printf("No\n");
54     }
55     return 0;
56 }
时间: 2024-10-07 05:41:13

HDU5926 Mr. Frog’s Game的相关文章

HDU 5924 Mr. Frog’s Problem 【模拟】 (2016CCPC东北地区大学生程序设计竞赛)

Mr. Frog's Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 312    Accepted Submission(s): 219 Problem Description One day, you, a clever boy, feel bored in your math class, and then fall

HDU 5926 Basic Mr. Frog’s Game 瞎搞

Mr. Frog’s Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1273    Accepted Submission(s): 625 Problem Description One day, Mr. Frog is playing Link Game (Lian Lian Kan in Chinese). In this

HDU5924 Mr. Frog’s Problem

1 /* 2 HDU5924 Mr. Frog's Problem 3 http://acm.hdu.edu.cn/showproblem.php?pid=5924 4 数论 5 * 6 */ 7 #include <cstdio> 8 int main() 9 { 10 long long a,b; 11 int t; 12 scanf("%d",&t); 13 for(int k=1;k<=t;k++) 14 { 15 scanf("%lld%l

hdu 5926.Mr. Frog’s Game

http://acm.hdu.edu.cn/showproblem.php?pid=5926 题意:判断给出的这个连连看能不能连上(一次就行) 水,在首行首列或者尾行尾列的需要判断一下自己这一行或者这一列有没有能连上的(四个角的行列都需要判断),然后是所有的都判断一下相邻的能不能连就可以了 啪啪啪打完开心的提交,emmmm居然wa了.....怎么看都没错,又重新看了一遍题的时候突然发现人家要的是只有首字母大写的yes和no.....我全大写了,真是个傻子2333 1 #include<iostr

HDU 5925 Coconuts 【离散化+BFS】 (2016CCPC东北地区大学生程序设计竞赛)

Coconuts Time Limit: 9000/4500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 524    Accepted Submission(s): 151 Problem Description TanBig, a friend of Mr. Frog, likes eating very much, so he always has dreams abou

HDU 5919 Sequence II(主席树+逆序思想)

Sequence II Time Limit: 9000/4500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1422    Accepted Submission(s): 362 Problem Description Mr. Frog has an integer sequence of length n, which can be denoted as a1,a2

HDU5916

Harmonic Value Description Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 287    Accepted Submission(s): 184Special Judge Problem Description The harmonic value of the permutation p1,p2,?pn is

HDU5914

Triangle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 336    Accepted Submission(s): 229 Problem Description Mr. Frog has n sticks, whose lengths are 1,2, 3?n respectively. Wallice is a bad m

HDU5918(KMP)

Sequence I Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 729    Accepted Submission(s): 277 Problem Description Mr. Frog has two sequences a1,a2,?,an and b1,b2,?,bm and a number p. He wants to