1 / 9

11523: Recycling

11523: Recycling. ★★★☆☆ 題組: Contest Volumes with Online Judge 題號: 11523: Recycling 解題者: 歐尚錞 解題日期: 20 13 年 5 月 30 日 題意: 大寫代表不可回收物,小寫代表可回收物,連續相同的可回收物可算一次動作回收,問將可回收物全部回收需要多少次動作。輸入 T(T<50) 代表要做幾次回收,每次回收 N(N<100) 個物品,每個物品字元數最多 20 個 char 。. 題意範例: 3 (T) 5

Télécharger la présentation

11523: Recycling

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. 11523: Recycling • ★★★☆☆ • 題組:Contest Volumes with Online Judge • 題號:11523: Recycling • 解題者:歐尚錞 • 解題日期:2013年5月30日 • 題意:大寫代表不可回收物,小寫代表可回收物,連續相同的可回收物可算一次動作回收,問將可回收物全部回收需要多少次動作。輸入T(T<50)代表要做幾次回收,每次回收N(N<100)個物品,每個物品字元數最多20個char。

  2. 題意範例:3(T) 5 paper glass paper AEROSOL paper Case 1: 3 Move 1 : paper – paper – AEROSOL – paper Move 2 : AEROSOL – paper Move 3 : AEROSOL • 解法:DP

  3. 解法範例:ary[i][j]代表的意義為「從第i個開頭到第j個的最小動作次數」解法範例:ary[i][j]代表的意義為「從第i個開頭到第j個的最小動作次數」

  4. 解法範例:ary[i][j]代表的意義為「從第i個開頭到第j個的最小動作次數」解法範例:ary[i][j]代表的意義為「從第i個開頭到第j個的最小動作次數」 距離為1的點,從row=0~4和前一字串比對 相同:min(ary[row][column]), ary[row][column-1]); 不同且為可回收物: min(ary[row][column]), ary[row][column-1])+1); 且每次都必須往回檢查至0或不可回收物,碰到相同的則 min(ary[row][column]), row~檢查點+檢查點+1~column-1);

  5. 解法範例:ary[i][j]代表的意義為「從第i個開頭到第j個的最小動作次數」解法範例:ary[i][j]代表的意義為「從第i個開頭到第j個的最小動作次數」 距離為2的點,從row=0~4和前一字串比對

  6. 解法範例:ary[i][j]代表的意義為「從第i個開頭到第j個的最小動作次數」解法範例:ary[i][j]代表的意義為「從第i個開頭到第j個的最小動作次數」 距離為2的點,從row=0~4和前一字串比對

  7. 解法範例:ary[i][j]代表的意義為「從第i個開頭到第j個的最小動作次數」解法範例:ary[i][j]代表的意義為「從第i個開頭到第j個的最小動作次數」 距離為3的點,從row=0~4和前一字串比對

  8. 解法範例:ary[i][j]代表的意義為「從第i個開頭到第j個的最小動作次數」解法範例:ary[i][j]代表的意義為「從第i個開頭到第j個的最小動作次數」 距離為4的點,從row=0~4和前一字串比對

  9. 討論: (1)有用到greedy algorithm,每次都取最小

More Related