140 likes | 224 Views
HKOI 2008 FINAL EVENT Q3 STORAGE BOX. Hackson Leung 2007-12-29. AGENDA. Statistics Problem Descriptions Pre-requisite Wrong Solutions “Correct” Solutions Correct Solution(s) Discussion. STATISTICS. Min = 0 Max = 100 #Max = 3 Mode = 0. PROBLEM DESCRIPTIONS.
E N D
HKOI 2008 FINAL EVENT Q3STORAGE BOX Hackson Leung 2007-12-29
AGENDA • Statistics • Problem Descriptions • Pre-requisite • Wrong Solutions • “Correct” Solutions • Correct Solution(s) • Discussion
STATISTICS • Min = 0 • Max = 100 • #Max = 3 • Mode = 0
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
PRE-REQUISITE • Data Processing • Simple geometry concept • Basic Recursion technique
WRONG SOLUTIONS • Wrong → 0 marks • They contribute to correct solutions
WRONG SOLUTIONS • Hardcode • Remove-all • Naïve removal
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
NAÏVE REMOVAL • Can pass sample I/O • Can correctly determine no-removal-case • Problem(s) • Easy to construct the sequence? • Always correct? Target
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
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?
OBSERVATION (ADVANCED) Target
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?
POSSIBLE EXTREME CASE Target