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 d=40960d = 40960 milliseconds. Since 44.1 kHz means 44.1 samples per millisecond, each file contains

size=44.1d=1806336\text{size} = 44.1d = 1806336

amplitude samples. We represent each audio file as the sequence of amplitude samples

a0,a1,,asize1.a_0, a_1, \ldots, a_{\text{size}-1}.

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 3212=122883 \cdot 2^{12} = 12288 10/310/3 ms 147
2 3211=61443 \cdot 2^{11} = 6144 20/320/3 ms 294
3 3210=30723 \cdot 2^{10} = 3072 40/340/3 ms 588
4 329=15363 \cdot 2^9 = 1536 80/380/3 ms 1176
5 328=7683 \cdot 2^8 = 768 160/3160/3 ms 2352
6 327=3843 \cdot 2^7 = 384 320/3320/3 ms 4704
7 326=1923 \cdot 2^6 = 192 640/3640/3 ms 9408
8 325=963 \cdot 2^5 = 96 1280/31280/3 ms 18816
9 324=483 \cdot 2^4 = 48 2560/32560/3 ms 37632
10 323=243 \cdot 2^3 = 24 5120/35120/3 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
\ldots \ldots \ldots
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 ss starts 30(s1)30(s - 1) minutes after the contest starts. For record rr in that stage, the submission window is open from 30(s1)+3(r1)30(s - 1) + 3(r - 1) to 30(s1)+3r30(s - 1) + 3r 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 nn be the number of chunks in that record, and let chunk_size\text{chunk\_size} be the number of samples in one chunk. If the corrupted audio is

b0,b1,,bsize1,b_0, b_1, \ldots, b_{\text{size}-1},

then chunk ii of the corrupted audio is

chunki=[bchunk_sizei,bchunk_sizei+1,,bchunk_size(i+1)1].\text{chunk}_i = [b_{\text{chunk\_size}\cdot i}, b_{\text{chunk\_size}\cdot i + 1}, \ldots, b_{\text{chunk\_size}\cdot (i + 1) - 1}].

Your answer must be a permutation

p0,p1,,pn1p_0, p_1, \ldots, p_{n-1}

of the integers from 00 to n1n - 1. The meaning of this permutation is:

chunkp0chunkp1chunkpn1\text{chunk}_{p_0} \circ \text{chunk}_{p_1} \circ \ldots \circ \text{chunk}_{p_{n-1}}

should be the original audio file. Here \circ denotes sequence concatenation. In other words, pjp_j is the index of the corrupted chunk that you place at position jj 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 ss and record rr 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 nn space-separated integers:

p0,p1,,pn1.p_0, p_1, \ldots, p_{n-1}.

The submitted sequence must be a permutation of the integers from 00 to n1n - 1.

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 pp, let S(p)S(p) be the sequence of chunks obtained by applying this permutation:

S(p)=(chunkp0,chunkp1,,chunkpn1).S(p) = (\text{chunk}_{p_0}, \text{chunk}_{p_1}, \ldots, \text{chunk}_{p_{n-1}}).

Let S(original)S^{(\text{original})} be the sequence of chunks in the original audio file, and let S(output)=S(p(output))S^{(\text{output})} = S(p^{(\text{output})}) 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 S(output)S^{(\text{output})} or your score.

Two similarity measures are used:

  • lccs(S(1),S(2))\text{lccs}(S^{(1)}, S^{(2)}) is the maximum length of a contiguous block of chunks that appears in both sequences in the same order.
  • ncp(S(1),S(2))\text{ncp}(S^{(1)}, S^{(2)}) 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 (Si(1),Si+1(1))(S_i^{(1)}, S_{i+1}^{(1)}) over all 0i<n10 \le i < n - 1 and the multiset of pairs (Si(2),Si+1(2))(S_i^{(2)}, S_{i+1}^{(2)}) over all 0i<n10 \le i < n - 1.

If you do not submit an answer in time, or if your submitted sequence is not a permutation of the integers from 00 to n1n - 1, you receive 0 points for the record.

Otherwise, your points per record are

0.5lccs(S(original),S(output))1n1+0.5ncp(S(original),S(output))n1.0.5 \cdot \frac{\text{lccs}(S^{(\text{original})}, S^{(\text{output})}) - 1}{n - 1} + 0.5 \cdot \frac{\text{ncp}(S^{(\text{original})}, S^{(\text{output})})}{n - 1}.

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 points1,points2,,points10\text{points}_1, \text{points}_2, \ldots, \text{points}_{10} be the points obtained for records 11 through 1010 of one stage. The stage points are

i=110210ipointsi.\sum_{i=1}^{10} 2^{10-i} \cdot \text{points}_i.

Thus, earlier records have larger weights. The maximum possible points per stage is 10231023.

For each stage, the stage points are transformed into stage scores. If your stage points are your_stage\text{your\_stage} and the best points achieved by any team for this stage is best_stage\text{best\_stage}, then your stage score is

50your_stagebest_stage.50 \cdot \frac{\text{your\_stage}}{\text{best\_stage}}.

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

Sponsored by Joom

Sponsored by Joom