G. Plumbing the depth of lake

    传统题 1000ms 128MiB

Plumbing the depth of lake

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Description

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.

Input Format

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);

Output Format

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

第十届河南省ACM程序设计竞赛重现赛

未参加
状态
已结束
规则
XCPC
题目
9
开始于
2017-5-14 20:00
结束于
2017-5-15 1:00
持续时间
5 小时
主持人
参赛人数
50