博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
河南省第十届ACM省赛G:Plumbing the depth of lake
阅读量:5306 次
发布时间:2019-06-14

本文共 2458 字,大约阅读时间需要 8 分钟。

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
#include
int dx[]={-1,-1,-1,0,0,1,1,1};int dy[]={-1,0,1,-1,1,-1,0,1};int main(){ int n,m,l; int a[55][55]; scanf("%d",&l); while(l--) { scanf("%d %d",&n,&m); memset(a,-1,sizeof(a)); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { scanf("%d",&a[i][j]); } } int maxx=-9999; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { if(maxx>=a[i][j]) continue; for(int k=0;k<8;k++) { if(a[i][j]==a[dx[k]+i][dy[k]+j]) { maxx=a[i][j]; break; } } } } printf("%d\n",maxx); } return 0;}

转载于:https://www.cnblogs.com/nanfenggu/p/7900161.html

你可能感兴趣的文章
机器视觉:SSD Single Shot MultiBox Detector
查看>>
201521123044 《Java程序设计》第1周学习总结
查看>>
MIT Scheme 的基本使用
查看>>
程序员的“机械同感”
查看>>
在16aspx.com上下了一个简单商品房销售系统源码,怎么修改它的默认登录名和密码...
查看>>
c++回调函数
查看>>
linux下Rtree的安装
查看>>
【Java】 剑指offer(53-2) 0到n-1中缺失的数字
查看>>
Delphi中ListView类的用法
查看>>
多米诺骨牌
查看>>
Linq 学习(1) Group & Join--网摘
查看>>
asp.net 调用前台JS调用后台,后台掉前台JS
查看>>
Attribute(特性)与AOP
查看>>
苹果手表:大方向和谷歌一样,硬件分道扬镳
查看>>
Competing Consumers Pattern (竞争消费者模式)
查看>>
Android面试收集录15 Android Bitmap压缩策略
查看>>
PHP魔术方法之__call与__callStatic方法
查看>>
ubuntu 安装后的配置
查看>>
web前端之路,js的一些好书(摘自聂微东 )
查看>>
【模板】对拍程序
查看>>