125. Chord Identification

Codeforces
IDCF10269125
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
You're listening to music, and you hear a major chord of three notes. You want to figure out which chord you just heard. In music, the notes in a single octave, from lowest to highest, are as follows: C, C#, D, D#, E, F, F#, G, G#, A, A#, and B. Any two adjacent notes in this list are a "half step" apart. For example, C and D differ by 2 half steps, and A and D differ by 5 half steps. Additionally, notes can be represented as both sharps and flats. For example, C# and D ♭ (D flat) are the same note, and D# and E ♭ are the same note. A flat note will be represented with a lowercase f in the input, such as "Df" for D flat. A major chord has a $r o o t$, a $t h i r d$ note, and a $f i f t h$ note. The root and the third note must differ by exactly four half steps, and the third and fifth note must differ by exactly three half steps. Correspondingly, the root and the fifth note must differ by exactly seven half steps. Given this information, and a major chord, figure out what the root of the chord is. *The notes of the chord can be given in any order, i.e. the root doesn't necessarily come first.* The only line of input contain three space-separated notes. It is guaranteed that the notes form a major chord with the root being one of the three notes. Output a single note: the root of the chord. ## Input The only line of input contain three space-separated notes. It is guaranteed that the notes form a major chord with the root being one of the three notes. ## Output Output a single note: the root of the chord. [samples]
**Definitions** Let $ N = \{C, C\#, D, D\#, E, F, F\#, G, G\#, A, A\#, B\} $ be the set of 12 pitch classes in one octave, ordered cyclically. Let $ f: N \to \mathbb{Z}_{12} $ be the mapping: $ f(C) = 0, f(C\#) = 1, f(D) = 2, f(D\#) = 3, f(E) = 4, f(F) = 5, f(F\#) = 6, f(G) = 7, f(G\#) = 8, f(A) = 9, f(A\#) = 10, f(B) = 11 $. Define equivalent representations: $ C\# \equiv Df $, $ D\# \equiv Ef $, $ F\# \equiv Gf $, $ G\# \equiv Af $, $ A\# \equiv Bf $. Let $ S = \{n_1, n_2, n_3\} \subseteq N $ be the three input notes (in any order), each normalized to sharp form via equivalence. **Constraints** 1. $ S $ forms a major chord: there exists a root $ r \in S $ such that the other two notes $ n_i, n_j \in S \setminus \{r\} $ satisfy: $$ |f(n_i) - f(r)|_{12} = 4 \quad \text{and} \quad |f(n_j) - f(n_i)|_{12} = 3 $$ (where $ |x|_{12} $ denotes the minimal circular distance modulo 12). 2. Equivalently: the three notes correspond to pitch classes $ \{r, r+4, r+7\} \mod 12 $. **Objective** Find $ r \in S $ such that $ \{f(r), f(r)+4, f(r)+7\} \mod 12 = \{f(n_1), f(n_2), f(n_3)\} $. Output the note name corresponding to $ r $.
API Response (JSON)
{
  "problem": {
    "name": "125. Chord Identification",
    "description": {
      "content": "You're listening to music, and you hear a major chord of three notes. You want to figure out which chord you just heard. In music, the notes in a single octave, from lowest to highest, are as follows",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269125"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You're listening to music, and you hear a major chord of three notes. You want to figure out which chord you just heard.\n\nIn music, the notes in a single octave, from lowest to highest, are as follows...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ N = \\{C, C\\#, D, D\\#, E, F, F\\#, G, G\\#, A, A\\#, B\\} $ be the set of 12 pitch classes in one octave, ordered cyclically.  \nLet $ f: N \\to \\mathbb{Z}_{12} $ be the mapping:  \n$ ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments