Beat the Feat
You can now download tests for this problem here.
IMPORTANT: Do not postpone reading this statement. Each output file can be submitted only during its own three-minute window, and some of these windows may already have closed.
A group of attackers has created malware that targets audio archives. Instead of deleting recordings or encrypting them, it quietly corrupts WAV files by cutting each recording into equal-sized pieces and shuffling those pieces in a random order. The original permutations are lost forever, and the only remaining hope is a miracle: reconstructing the recordings from the corrupted audio itself. Your task is to perform that miracle. This is a secret task and a matter of the highest national importance, so do not tell anyone!
All original audio files are WAV files in 16-bit, 44.1 kHz, mono LPCM format. Each file has a duration of exactly milliseconds. Since 44.1 kHz means 44.1 samples per millisecond, each file contains
amplitude samples. We represent each audio file as the sequence of amplitude samples
To corrupt an audio file, the malware splits it into equal-sized chunks and concatenates those chunks in a random non-identity order.
Competition Format
You need to restore 48 original audio files. Restoring one original audio file is called a stage. In each stage, you work with 10 corrupted records generated from that original file.
Each record is a new corrupted version of the stage's original audio file, produced using the chunk size for that record. The permutation used in each record is generated independently and is guaranteed not to be the identity permutation.
The records within a stage go from hardest to easiest:
| Record | Number of chunks | Chunk duration | Samples per chunk |
|---|---|---|---|
| 1 | ms | 147 | |
| 2 | ms | 294 | |
| 3 | ms | 588 | |
| 4 | ms | 1176 | |
| 5 | ms | 2352 | |
| 6 | ms | 4704 | |
| 7 | ms | 9408 | |
| 8 | ms | 18816 | |
| 9 | ms | 37632 | |
| 10 | ms | 75264 |
The number of chunks halves after each record, so later records contain longer chunks.
Contest Schedule
During the contest, stages are released sequentially. Stage 1 occupies the first 30 minutes, stage 2 occupies the next 30 minutes, and so on until stage 48. The full schedule lasts 24 hours, which is the whole contest duration.
The stage schedule is:
| Contest time (hh:mm) | Stage | Output files in this stage |
|---|---|---|
| 00:00–00:30 | 1 | 01-01.txt through 01-10.txt |
| 00:30–01:00 | 2 | 02-01.txt through 02-10.txt |
| 23:30–24:00 | 48 | 48-01.txt through 48-10.txt |
Within each stage, records are released sequentially. Record 1 becomes available when the stage starts, and then a new record becomes available every 3 minutes. For each record, the submission window lasts exactly 3 minutes, and you may submit at most one answer for that record.
For a stage with two-digit number SS, the schedule inside the stage is:
| Time since stage start (mm:ss) | Record | Output file |
|---|---|---|
| 00:00–03:00 | 1 | SS-01.txt |
| 03:00–06:00 | 2 | SS-02.txt |
| 06:00–09:00 | 3 | SS-03.txt |
| 09:00–12:00 | 4 | SS-04.txt |
| 12:00–15:00 | 5 | SS-05.txt |
| 15:00–18:00 | 6 | SS-06.txt |
| 18:00–21:00 | 7 | SS-07.txt |
| 21:00–24:00 | 8 | SS-08.txt |
| 24:00–27:00 | 9 | SS-09.txt |
| 27:00–30:00 | 10 | SS-10.txt |
Equivalently, stage starts minutes after the contest starts. For record in that stage, the submission window is open from to minutes after the contest starts.
Once the submission window for a record ends, you can no longer submit an answer for that record. Records are independent for submission purposes: even if you restore the original audio while solving an earlier record, you still need to submit a separate file for every record where you want to receive points.
Required Permutation
Consider one record. Let be the number of chunks in that record, and let be the number of samples in one chunk. If the corrupted audio is
then chunk of the corrupted audio is
Your answer must be a permutation
of the integers from to . The meaning of this permutation is:
should be the original audio file. Here denotes sequence concatenation. In other words, is the index of the corrupted chunk that you place at position in the restored audio.
Note: There may be equal chunks. You receive the maximum score for any permutation that reconstructs the original audio file exactly.
Record Data
At the start of the submission window for a record, the corrupted audio file for that record becomes available. The record number determines the number of chunks and the chunk size using the table above. You can download the corrupted audio from the contest system or obtain its download URL through the API.
You may also have downloaded the full test archive in advance from Discord. Use the password 41274070-9BF9-4780-989A-F5CA830E843B to open it. The test archive contains all corrupted audio files. Each file is stored in a separate inner archive, protected by its own password. The password for the currently active record is shown in the contest system and is also available through the API.
Submission Format
The output file for stage and record must be named SS-RR.txt, where SS is the two-digit stage number and RR is the two-digit record number. For example, the file for stage 1, record 1 is 01-01.txt, and the file for stage 48, record 10 is 48-10.txt.
Before the record's submission window ends, submit a text file containing exactly space-separated integers:
The submitted sequence must be a permutation of the integers from to .
The contest platform supports submitting answers through the API. Since this problem has many records and short submission windows, it may be useful to automate submissions through it.
Scoring
Record Scoring
For a permutation , let be the sequence of chunks obtained by applying this permutation:
Let be the sequence of chunks in the original audio file, and let be the sequence of chunks produced by your submitted permutation. In this section, two chunks are equal if their sequences of amplitude samples are exactly equal. Therefore, exchanging two equal chunks does not change or your score.
Two similarity measures are used:
- is the maximum length of a contiguous block of chunks that appears in both sequences in the same order.
- is the number of adjacent ordered chunk pairs shared by the two sequences, counted with multiplicity. Formally, it is the size of the intersection of the multiset of pairs over all and the multiset of pairs over all .
If you do not submit an answer in time, or if your submitted sequence is not a permutation of the integers from to , you receive 0 points for the record.
Otherwise, your points per record are
A perfect answer receives 1 point for the record. In particular, any submitted permutation that reconstructs the original audio file exactly receives 1 point. Only the first submission for each record is scored.
Stage Scoring
Let be the points obtained for records through of one stage. The stage points are
Thus, earlier records have larger weights. The maximum possible points per stage is .
For each stage, the stage points are transformed into stage scores. If your stage points are and the best points achieved by any team for this stage is , then your stage score is
Your total score for the problem is the sum of your normalized stage scores over all 48 stages.
Updated at Jul 4, 2026, 6:39 PM: In case you missed it, an endpoint to download past files in problem B has been added: https://finals.midnightcodecup.org/api-docs#tag/problems/GET/api/v1/problems/{slug}/scheduled-groups/past-tests
