Editorial for DMOPC '18 Contest 3 P1 - Bob and Music Class


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.

Author: Kirito

In this problem, we are given a triad of notes and asked to identify the type of triad it is based on the intervals between the notes.

There are multiple different ways of doing this. Due to the small number of possible triads, one can write code to enumerate all of them and the correct outputs.

For a solution that doesn't do any precomputation, note that augmented triads are easy to detect since the distance between two adjacent notes is always 4. All other triads have an interval where the distance is greater than 4, so we can count the number of rotations we need to make the distance between the last two notes greater than 4, which gives us the inversion. We can then read off the root and type of triad directly.


Comments

There are no comments at the moment.