Presentation is loading. Please wait.

Presentation is loading. Please wait.

HKOI 2008 FINAL EVENT Q3 STORAGE BOX

Similar presentations


Presentation on theme: "HKOI 2008 FINAL EVENT Q3 STORAGE BOX"— Presentation transcript:

1 HKOI 2008 FINAL EVENT Q3 STORAGE BOX
Hackson Leung

2 AGENDA Statistics Problem Descriptions Pre-requisite Wrong Solutions
“Correct” Solutions Correct Solution(s) Discussion

3 STATISTICS Min = 0 Max = 100 #Max = 3 Mode = 0

4 PROBLEM DESCRIPTIONS Given N books (by means of their co-ordinates)
Find the optimal way to remove books such that the Kth book is not covered by any book The sequence of removal is important Target

5 PRE-REQUISITE Data Processing Simple geometry concept
Basic Recursion technique

6 WRONG SOLUTIONS Wrong → 0 marks They contribute to correct solutions

7 WRONG SOLUTIONS Hardcode Remove-all Naïve removal

8 NAÏVE REMOVAL Project two vertical lines from two sides of the book
Whenever the lines intersect (not touch) any book that is higher than the target, it should be removed Intersect Target

9 NAÏVE REMOVAL Can pass sample I/O
Can correctly determine no-removal-case Problem(s) Easy to construct the sequence? Always correct? Target

10 OBSERVATIONS The books covering the Kth book are also removed
Suppose one of them is the Pth book If the Pth book is optimally removed, then the Kth book is also removed optimally The problem becomes: how to remove the Pth book in the optimal way? The Pth book The Kth book

11 CORRECT SOLUTION From previous slide, it seems that we are doing the same job again and again Unless the top objects are not removed, the one below should remain stationary First-In-Last-Out (FILO) property holds Why not use recursion to solve? Θ(N2), fast enough for N < 1,000 Way to improve?

12 OBSERVATION (ADVANCED)
Target

13 COMMON MISTAKES Correct source, wrong executable
Wrong determination of “covering” Poor implementation skills in recursion Wrong concept in local / global variables Wrong output sequence Does the sequence always follow FILO property?

14 POSSIBLE EXTREME CASE Target


Download ppt "HKOI 2008 FINAL EVENT Q3 STORAGE BOX"

Similar presentations


Ads by Google