Editorial for IOI '18 P4 - Mechanical Doll
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Subtask 1
- Connect triggers without switches.
Subtask 2
- Put a switch after each trigger which appears twice.
Subtask 3
- For each trigger which appears more than twice, use switches to branch its exit into exits (Imagine a balanced binary tree). For each trigger which appears times, kill one out of the first exits by connecting it to the "root" switch.
Subtask 4
- Gather exits of all the triggers into one, and branch it into exits with () switches.
Subtask 5
- (Solution A) ( switches, half score) Use switches for such that , and kill excessive exits by connecting them to the "root" switch.
- ( switches, full score) In addition to Solution A, skillfully choose which exits to kill so that they are closely placed in the circuit. Then many switches are now unnecessary because their exits are both connected to the "root" switch.
Subtask 6
- ( switches, half score) Do Solution A for every trigger.
- (Solution B) ( switches, half score) Gather exits of all the triggers into one, and branch it using Solution A.
- ( switches, full score) In addition to Solution B, save switches by skillfully choosing which exits to kill.
Comments