![]() |
||||||||||
|
||||||||||
Hidden Music ScoreTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 222 Accepted Submission(s): 77 Problem Description Do you like music? Let's play a game. I wrote down some notes on a piece of staff paper, then erase every other thing and leave only the notes. Can you guess what I wrote? If you're not familiar with music, take a look at the picture above. The vertical position of a note determines its name, which is one of C, D, E, F, G, A and B, in this problem (yes, you don't have to consider notes in other octaves). Consecutive lines in the staff have the same vertical distances. We call it one standard distance (sd), which is always between 1.0 and 5.0. For example, C and E are 1sd apart, and D and B are 2.5sd. The horizontal order of the notes determines how the sequence is played (or sung). The exact horizontal positions do not matter, as long as the relative order is preserved. But since I never write down ugly scores, you can safely assume that the horizontal distance of an arbitrary pair of neighboring notes is at least 1sd and at most 5sd. Figure 2(a) corresponds to the sequence EEECEG. Figure 2(b) shows the notes when other stuffs have been erased. Then, I rotate the paper and tell you the positions of the notes, shown in figure 2(c). Write a program to find my original music score, given the rotated positions of the notes. To make your life a little bit easier, I can tell you the name of the first and last note, and I promise that the answer could be uniquely determined. The rotation angle is an integer between -60 and 60 degrees (inclusive). Input The input consists of several test cases. The first line of each case contains one integer n (3 ≤ n ≤ 20) and two different capital letters from 'A' to 'G'. This is followed by n lines each containing two real numbers to eight decimal places, the rotated positions of each note. The notes can appear in any order. All the real numbers have absolute values not greater than 1000. The last test case is followed by a single zero, which should not be processed. Output For each test case, print the case number and recognized hidden score. The test cases are carefully designed such that floating error does not cause any problem. Sample Input
Sample Output
Source | ||||||||||
|