QOJ.ac

QOJ

时间限制: 1 s 内存限制: 1024 MB 总分: 100

#4198. 高音演唱

统计

Anton 是 Kongliga Teknologkören(KTH 合唱团)的一名著名合唱歌手。经过多年的政治周旋,他成功当选为合唱团主席。因此,他拥有决定合唱团活动的绝对权力,包括决定排练哪些曲目。

Anton 挑选了一首他非常喜欢的特定歌曲,希望合唱团能演唱这首歌。但有一个小问题——这首歌完全不适合他的音域。Anton 的音域是女低音(alto),他想确保乐曲中最关键的部分能完美契合他的嗓音。

这首乐曲目前使用 12 个标准音调编写,按升序排列为 C, C#, D, D#, E, F, F#, G, G#, A, A#, B,每个音调后跟一个整数,表示该音调出现的八度。最低八度为 1。在第 $i$ 个八度的 B 音之后,紧接着是第 $i+1$ 个八度的 C 音。

现在,Anton 想要移调这首乐曲,使得乐曲中的所有音调都在他的音域范围内(由他能唱的最低音和最高音给出)。移调意味着所有音调都向上或向下移动固定的音调数。例如,将 C#4(第四八度的 C#)向下移 5 个音调会变成 G#3。此外,Anton 不太擅长阅读乐谱。在所有有效的移调方案中,他只对那些能使变音记号(即带有 # 号的音符)数量最少的方案感兴趣。

给定乐曲和 Anton 的音域,你能确定有多少种这样的移调方案吗?

输入格式

第一行包含乐曲中的音调数量 $n$ ($1 \le n \le 1000$)。接下来一行包含两个音调,即 Anton 能唱的最低音和最高音(按此顺序)。第三行(最后一行)包含 Anton 乐曲中的音调。同一个音调在乐曲中可能会多次出现。保证 Anton 至少能唱该乐曲的一种移调方案。

每个音调写为 12 个音调之一(C, C#, D, D#, E, F, F#, G, G#, A, A#, B),紧随其后的是其八度,中间没有空格。仅使用 1 到 $10^9$ 之间的八度。

输出格式

输出一行,包含两个整数——在所有移调方案中变音记号(带有 # 的音符)的最小数量,以及保持乐曲在 Anton 音域内且变音记号数量最少的移调方案数量。如果乐曲本身已经在 Anton 的音域内,则移调 0 个音调的情况也应被计入(如果这能使变音记号最少)。

样例

样例输入 1

14
F3 F5
C4 C4 G4 G4 A4 A4 G4 F4 F4 E4 E4 D4 D4 C4

样例输出 1

0 3

样例输入 2

1
C#1 A#1
C1000000000

样例输出 2

0 5

样例输入 3

3
F3 F5
F3 F#3 F5

样例输出 3

1 1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.