問題一覧 > 通常問題

No.1905 PURE PHRASE

レベル : / AI推定難易度 : 1400 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 85
作問者 : 👑 hitonanode / テスター : Sumitacchan
お気に入りにしたユーザー ProblemId : 7039 / 自分の提出
問題文最終更新日: 2022-04-26 01:18:38
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 339 (順位表) の他の問題:

Problem Statement

You are given a sound waveform $\mathbf{A} = [A_1, \dots, A_{N}]$ of length $N = 44100$ (that is, $1$ second long) recorded at a sampling rate of $44100~\mathrm{Hz}$. That is, $A_i$ $(1 \le i \le N)$ is the displacement of the signal at time $i / N \ \mathrm{[sec]}$. This signal is a $1$-second excerpt of a performance sound imitating some musical instrument, and its pitch is one of C4, D4, E4, F4, G4, A4, B4. In this problem, you may assume that the fundamental frequencies of these notes are, in order, 261.6, 294.3, 327.0, 348.8, 392.4, 436.0, 490.5 $\mathrm{Hz}$ (regarding fundamental frequencies, see also the explanations of the samples). Determine which pitch is being played and output the answer.

Notes

The method used to create the test cases for this problem is described at the end of this page.

Input

$N$
$A_1\ A_2 \ \dots \ A_N$

  • $N = 44100$
  • $-32768 \le A_i \le 32767$ $(i = 1, \dots, N)$
  • All inputs are integers.

Output

Output the answer string (one of C4, D4, E4, F4, G4, A4, B4). Print a newline at the end.

Sample

Since small input data cannot be provided for this problem, the sample data has been prepared on GitHub Gist. Please download it from this link and use it as needed.
Sample 1
Input
Output
C4

This is the sound of C4 played by Trumpet.

The figure below shows the beginning of the waveform data of Sample 1, plotted with waveform analysis software (in the figures below, the unit of the horizontal axis is seconds).

Observing this, you can see that similar waveforms repeat with a period of about $0.0038$ seconds. Taking the reciprocal of this period, you find that this waveform appears about $260$ times per $1$ second. This corresponds to the fundamental frequency of the note C4 being about $261.6 \mathrm{Hz}$. A characteristic of the input is that shifting the entire waveform (sequence) forward or backward by about $N / 261.6$ elements does not change the appearance of the data very much.

Sample 2
Input
Output
D4

This is the sound of D4 played by Pan Flute. The waveform is shown below.

Observing this, you can see that similar waveforms repeat with a period of $0.0034$ seconds. Taking the reciprocal gives about $294 \mathrm{Hz}$, which roughly matches the fundamental frequency of D4.

Sample 3
Input
Output
E4

This is the sound of E4 played by Recorder. The waveform is shown below.

Supplement: How the Test Cases Were Created

The test cases used to judge submitted code in this problem were created by the following method.

  • Using the software synthesizer Cakewalk TTS-1 on the DAW software Cakewalk by BandLab, a wav file is created in which a single note, one of C4, D4, E4, F4, G4, A4, B4, is played for 8 seconds. The tones used were the presets Harmonica, Violin, Trumpet, Shakuhachi, Pan Flute, Alto Sax, Church 1, Recorder. The format of the wav signal was a sampling rate of $44100~\mathrm{Hz}$ and a bit depth of $16$ bit. The pitch was also finely adjusted, but other settings were basically left unchanged from the defaults.
  • A contiguous segment exactly $1$ second long is cut out from the created wav file and used as the input of a test case. The position of the cut may have been chosen arbitrarily by the problem setter.
It has been confirmed that the code prepared as the intended solution for this problem produces correct answers for all of the $41$ test cases used for judging in this problem, as well as for $10^5$ additional test cases randomly generated under the above conditions.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。