title: Plumbing the depth of lake 河南省第十届省赛

题目描述:

There is a mysterious lake in the north of Tibet. As the sun shines, the surface of the lake is colorful and colorful. The lake was unfathomable in rainy weather.  After the probe,  It has an interesting bottom in that it is full of little hills and valleys. .** **Scientists wonders how deep the bottom of the lake is.

Scientists use the most advanced radar equipment to detect the bottom of the lake. It is the discovery that the deepest part is relatively flat. Thet want to know the largest depth number only if it is verified by the fact that the same depth appears in an adjacent reading.

To facilitate computing, scientists have put the lake as M * N grids .*The depth  reading of each grid is already known. some readings might be 0-- It's a small island on the lake.

Find the greatest depth that appears in at least two 'adjacent'readings (where 'adjacent' means in any of the potentially eight squares that border a square on each of its sides and its diagonals). The lake has at least one pair of positive, adjacent readings.

输入:

The first line of the input contains one integers T, which is the nember of  test cases (1<=T<=5).  Each test case specifies:

  • Line 1:      Two space-separated integers: M and N   (1 ≤ M,  N ≤ 50)

  • Lines 2..M+1: Line i+1 contains N space-separated integers that  represent the depth of the lake across row i: Dij    (0 <= Dij <=1,000,000);

输出:

For each test case generate a single line:  a single integer that is the depth of the lake determined.

样例输入:

1
4 3
0 1 0
1 2 0
1 5 1
2 3 4

样例输出:

1

分析:

找出湖底的只要有两个单位面积相连(八个方向)的最大的深度,跟这个深度面积的大小没有关系。

代码:

#include <cstdio>
#include <cstring>
int Map[55][55];
int dx[8] = {-1,-1,-1,0,0,1,1,1};
int dy[8] = {-1,0,1,-1,1,-1,0,1};
int Max;
void Search(int i,int j)
{
int k;
if(Map[i][j]==-1) return ; if(Max >= Map[i][j]) return ;///找出深度最大的 for(k=0; k<8; k++)
{
if(Map[i][j] == Map[i + dx[k]] [j + dy[k]]) ///八个方向找一下,只要有一个就行,有就更新 Max
{
Max = Map[i][j];
break;
}
}
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
Max = -1;
int i,j,m,n;
scanf("%d%d",&m,&n);
memset(Map,-1,sizeof(Map));
for(i=1; i<=m; i++)
{
for(j=1; j<=n; j++)
{
scanf("%d",&Map[i][j]);
}
}
for(i=1; i<=m; i++)
{
for(j=1; j<=n; j++)
{
Search(i,j);
}
}
printf("%d\n",Max);
}
return 0;
}

河南省第十届省赛 Plumbing the depth of lake (模拟)的更多相关文章

  1. 河南省第十届省赛 Intelligent Parking Building

    title: Intelligent Parking Building 河南省第十届省赛 tags: [模拟,省赛] 题目描述: There is a new revolution in the pa ...

  2. 河南省第十届省赛 Binary to Prime

    题目描述: To facilitate the analysis of  a DNA sequence,  a DNA sequence is represented by a binary  num ...

  3. 四川第十届省赛 A.Angel Beats bitset

    四川第十届省赛 A.Angel Beats bitset 题目链接 题解参考:http://www.cnblogs.com/Aragaki/p/9142250.html 考虑用bitset来维护对于所 ...

  4. 每天一套题打卡|河南省第十届ACM/ICPC

    A.谍报分析 题意:请你编程,快速统计出频率高的前十个单词. 思路:字符串输入,map哈希表map<string,int >记录每个单词出现的次数,pair重载优先级 #include&l ...

  5. 河南省acm第九届省赛--《表达式求值》--栈和后缀表达式的变形--手速题

    表达式求值 时间限制:1000 ms | 内存限制:65535 KB 难度:3   描述 假设表达式定义为:1. 一个十进制的正整数 X 是一个表达式.2. 如果 X 和 Y 是 表达式,则 X+Y, ...

  6. 【河南省第十届ACM 省赛 A-谍报分析】

    题目描述 “八一三”淞沪抗战爆发后,*几次准备去上海前线视察和指挥作战.但都因为宁沪之间的铁路和公路遭到了敌军的严密封锁,狂轰滥炸,一直未能成行. 特科组织,其主要任务是保卫的安全,了解和掌握敌方的动 ...

  7. CSU 1511 残缺的棋盘 第十届湖南省赛题

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1511 题目大意:在一个8*8的棋盘中,给你一个起点位置和一个终点位置,同时也给你一个陷阱 ...

  8. CSU 1507 超大型LED显示屏 第十届湖南省赛题

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1507 解题思路:这是一道模拟题,看了那么多人的代码,我觉得我的代码是最简的,哈哈,其实就 ...

  9. 福州大学第十届校赛 & fzu 2128最长子串

    思路: 对于每个子串,求出 母串中 所有该子串 的 开始和结束位置,保存在 mark数组中,求完所有子串后,对mark数组按 结束位置排序,然后 用后一个的结束位置 减去 前一个的 开始 位置 再 减 ...

随机推荐

  1. C++学习013多态

    何为多态 面向对象最要的特征之一就是多态,而纯虚函数是实现多态的主要方式.它可以提供一个通过用的接口,同样调用一个方法, 由于运算对象不同,方法也不同,这也就是所谓的动态绑定. #include &l ...

  2. mysql 5.7.18 源码安装笔记

    之所以贴出这样一篇笔记呢?主要是因为很久之前,源码安装MySQL的时候,碰到了太多太多的坎坷. 如果你有兴趣进行源码安装,那么请不要以这篇文章为标准,因为每个人的及其环境等其他因素还是差距比较大的. ...

  3. Windows Server2003下安装IIS服务脑图

    在练习过程中,勾选“ASP.NET”后开始安装时提示要插入安装光盘,但是我安装系统时是用镜像文件在虚拟机里安装的,所以根据提示界面的提示从文件中选择相应文件复制,如下图点击确定,选择iisapp.vb ...

  4. truffle自动化测试脚本

    truffle自动化测试脚本 补充一个unbox 1.部署本地ganache环境 配置文件地址为本地地址 localhost:XXXX 上线的环境为 infura的url 2.命令: truffle ...

  5. 树莓派搭建 Hexo 博客(二)

    Hexo 一个开源的博客框架,本文记录了一下在树莓派上搭建 Hexo 博客的过程. 上一篇介绍了 Hexo 的配置,现在网站已经能在本地访问了,也能通过 hexo generate 命令生成静态界面 ...

  6. u盘中毒后文件夹没显示了

    今日,我的U盘插了有毒的电脑,直接中毒了,先是显示有木马,后是自行产生一些文件,接着文件夹没了,后来自己终于解决了,分享一下,自己先用工具将有嫌疑的文件提炼出来,经自行检查后处理,接着打开文件夹选项, ...

  7. 简单java采集程序一

    [目标任务]通过该网站采集全国的手机号码段至数据库表中 [完成过程] 1.初涉正则表达式,学会写简单的正则表达式 2.获取单个网页内容,学会java中基本的IO流 3.将获取数据插入mysql数据库表 ...

  8. Java课程设计--学生成绩管理系统

    一.团队名称: 团队成员 林艺薇 201721123032 网络1712 黄毓颖 201721123033 网络1712 唐川 201721123034 网络1712 梁才玉 201721123038 ...

  9. Nginx学习笔记之加强篇

    在上一篇文章Nginx学习笔记之应用篇中,我们已经可以正式运行自己的网站了.但是在使用Nginx服务器时还需要注意几个问题: 1.Nginx服务器上配置的单个站点的并发量不超过1024 2.Nginx ...

  10. spring笔记(三)

    Spring 第二天: 1. 代理模式 2. Aop编程 3.Spring对Jdbc的支持 JdbcTemplate工具类 思考: 程序的“事务控制”, 可以用aop实现! 即只需要写一次,运行时候动 ...