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 解題者: 柯名澤 、林一帆 解題日期: 2006年 4 月 23 日 題意: 給一 R x C 的矩陣 (R 與 C 小於 100) ,其中每元素的值代表 高度 ,若一個滑雪者只能從鄰近的地方 由高往低處滑 ,求出這個矩陣中最長的一段路徑 (Time limit: 5secs Memory limit: 32MB). 1 2 3 4 5

egan
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 • 解題者:柯名澤、林一帆 • 解題日期:2006年4月23日 • 題意:給一R x C的矩陣(R與C小於100),其中每元素的值代表高度,若一個滑雪者只能從鄰近的地方由高往低處滑,求出這個矩陣中最長的一段路徑(Time limit: 5secs Memory limit: 32MB)

  2. 1 2 3 4 5 1617 18 19 6 15 2425 20 7 14 23 22 21 8 13 12 11 10 9 • 題意範例: 24-17-16-1為一可能路徑 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 25-24-23-...-3-2-1也為一可能路徑 … 找出最長的路徑並印出路徑長 (此例中25即為最長路徑長)

  3. 求出每一點可走的最長路徑求法為:求出該點四個方向(題目限定)所能走的最長路徑的最長的就是該點可能走到的最長路徑求出每一點可走的最長路徑求法為:求出該點四個方向(題目限定)所能走的最長路徑的最長的就是該點可能走到的最長路徑 • 在求出每點的最長路徑時若該方向還可以往下走則使用recursive的方法再求那點的最長路徑 • 對每個運算過的最長路徑把值存起來,如此在下次再用到這個值的時候,可以立即回傳 • 解法 1 2 3 4 5 16 17 18 19 6 1524 25 20 7 14 23 22 21 8 1312 11 10 9 …

  4. 討論: 因為題目限定長跟寬不超過一百且最多15個case故大約需要15 x (100 x 100 x2) x 4bytes = 120kb 因為每個元素只需要執行一次,時間複雜度應為O(R*C*n) 使用一相同大小的矩陣存算過的值

More Related