日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

河南省第十届省赛 Plumbing the depth of lake (模拟)

發(fā)布時(shí)間:2024/9/5 编程问答 53 豆豆
生活随笔 收集整理的這篇文章主要介紹了 河南省第十届省赛 Plumbing the depth of lake (模拟) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

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

分析:

找出湖底的只要有兩個(gè)單位面積相連(八個(gè)方向)的最大的深度,跟這個(gè)深度面積的大小沒有關(guān)系。

代碼:

#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]]) ///八個(gè)方向找一下,只要有一個(gè)就行,有就更新 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; }

轉(zhuǎn)載于:https://www.cnblogs.com/cmmdc/p/6887914.html

總結(jié)

以上是生活随笔為你收集整理的河南省第十届省赛 Plumbing the depth of lake (模拟)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。