1 / 4

10285: Longest Run on a Snowboard

10285: Longest Run on a Snowboard. ★★★☆☆ 題組: Problem C – GWCF Contest 1 題號: 10285: Longest Run on a Snowboard 解題者 : 羅睿 解題日期: 20 14 年 5 月 29 日 題意 : 給定一個大小為 R*C(R,C<100) 的滑雪地地圖,每格的內容都是其高度 (0-100) ,只能由高往低處滑,試求出每個人可滑行最長距離。. 題意範例:. 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7

sera
Download Presentation

10285: Longest Run on a Snowboard

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 10285: Longest Run on a Snowboard • ★★★☆☆ • 題組:Problem C – GWCF Contest 1 • 題號:10285: Longest Run on a Snowboard • 解題者:羅睿 • 解題日期:2014年5月29日 • 題意:給定一個大小為R*C(R,C<100)的滑雪地地圖,每格的內容都是其高度(0-100),只能由高往低處滑,試求出每個人可滑行最長距離。

  2. 題意範例: 1 2 3 4 5 16 17 18 19 6 15 24 2520 7 14 23 22 21 8 13 12 11 10 9 24-17-16-1為其中一條可能的路徑 25-24-23-...-3-2-1也是一條可能路徑,因為這條路徑為最長可能,所以此題的解為25

  3. Feldberg 10 5 56 14 51 58 88 26 94 24 39 41 24 16 8 51 51 76 72 77 43 10 38 50 59 84 81 5 23 37 71 77 96 10 93 53 82 94 15 96 69 9 74 0 62 38 96 37 54 55 82 38 • 解法: (1) 使用DFS搜尋法輪流從每個點的 四個方向去找比其值小且未出界 的點,若有符合條件則recursive 從這個點繼續找下去,將目前最長 路徑用常數存起來。 (2) 用一個大小與地圖相等的陣列來 存每個點能走的最長路徑,方便 被呼叫時可直接使用。 (3) 地圖外圍用-1包起來,方便判斷 邊界。

  4. 討論: 因為每個元素只需要執行一次,時間複雜度為O(R*C*4)= O(R*C)

More Related