Ivan Li Background A peaceful sports event of innocent cute little penguins mercilessly destroyed by Big Bad Monsters In short Single elimination tournament Tree structure Taller penguin wins ID: 311797
Download Presentation The PPT/PDF document "HKOI Senior Q2 - Igloo" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
HKOI Senior Q2 - Igloo
Ivan LiSlide2
Background
A peaceful sports event of innocent cute little penguins......
mercilessly destroyed by Big Bad Monsters!Slide3
In short
Single elimination tournament
Tree structure
Taller penguin wins
In case of a tie, compare indexMust not let monsters win!Slide4
Direct simulation
Stores the penguins in an array, and simulate the competition process
After some tedious typing work, you get 50%Slide5
When there is no monsters
The tallest penguin wins
If tie, the lowest index
Hurrah! 20%!Slide6
When monsters step in
They may beat the potential winners
Good news – monsters live in the same igloo. Their indexes are consecutiveSlide7
Observation 1
When the monsters are not the tallest, we don’t have to be afraid of them
Just ignore themSlide8
Observation 2
When the monsters on the left subtree, all normal penguins in that subtree will be beaten.
Only consider the right subtree
Similar holds for right subtreeSlide9
Full Solution
Call the penguins on the left(right) of the monsters “the left(right) band”.
Find the largest subtree that is included in the bands
Lengths must be power of 2
Which subtree survives longer?
The taller (larger) one
Tie – the right one
The tallest penguin in that subtreeSlide10
Full SolutionSlide11
Alternative solution
Maintain the start and end index of each igloo
Simulate the rounds
Calculate the boundaries
Match on the boundaries?Who wins?Slide12
Questions?