第十届ACM省赛-E Plumbing the depth of lake
2017-05-21 21:34
411 查看
问题 G: 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 inthat 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<iostream> #include<algorithm> #include<cstring> using namespace std; int x[8]={-1,-1,-1,0,0,1,1,1}; int y[8]={-1,0,1,-1,1,-1,0,1}; int main() { int t,i,j; int a[100][100]; cin>>t; while(t--) { int max=-1; //初值附为-1 int m,n; memset(a,-1,sizeof(a)); cin>>m>>n; for(i=0;i<m;i++) { for(j=0;j<n;j++) { cin>>a[i][j]; } } for(i=0;i<m;i++) { for(j=0;j<n;j++) { if(max>=a[i][j]) { continue; } for(int k=0;k<8;k++) { if(a[i][j]==a[i+x[k]][j+y[k]]) //八个方向 { max=a[i][j]; break; } } } } cout<<max<<endl; } }
相关文章推荐
- 河南省第十届ACM省赛G:Plumbing the depth of lake
- 河南省第十届ACM省赛题目:问题 G: Plumbing the depth of lake
- G Plumbing the depth of lake 河南第十届ACM真题 【搜索】
- 2017年河南省ACM省赛 Problem G: Plumbing the depth of lake
- 问题 G: Plumbing the depth of lake
- 省赛 Plumbing the depth of lake
- 山东省第八届acm省赛 Return of the Nim
- 2013山东省第四届ACM省赛 The number of steps
- 山东省第八届ACM省赛A.Return of the Nim
- 杭电(hdu)ACM 1010 Tempter of the Bone
- The Phantom of the Opera-9、The house on the lake
- Book Contents Reviews Notes Errata Articles Talks Downloads Resources Code Formatter Cover of C# in Depth Order now (3rd edition) Implementing the Singleton Pattern in C#
- 10496: Cross the River —— 郑州大学第十届ACM大学生程序设计竞赛正式赛
- 2017 ACM-ICPC 亚洲区(青岛赛区)网络赛 HDU 6208 1003 The Dominator of Strings(AC自动机)
- 第十届ACM省赛-C 最小秘钥
- 渣渣ACM日记——1010-Tempter of the Bone (HDOJ)
- HDU ACM 3006 The Number of set (位运算)
- Write a function to find the depth of a binary tree
- Problem 1046 Tempter of the Bone, from http://acm.fzu.edu.cn/problem.php?pid=1046
- 杭电(hdu)ACM 1010 Tempter of the Bone