hackercupai/hackercup
Data Preview The data available in this preview contains a 10 row dataset: Sample Dataset ("sample"): This is a subset of the full dataset, containing data from 2023. To view full dataset, download output_dataset.parquet. This contains data from 2011 to 2023. Fields The dataset include the following fields: name (string) year (string) round (string) statement (string) input (string) solution (string) code (string) sample_input (string) sample_output (string)… See the full description on the dataset page: https://huggingface.co/datasets/hackercupai/hackercup.
242.2k
1**Note: The only difference between this problem and [problem C1](https://www.facebook.com/codingcompetitions/hacker-cup/2022/qualification-round/problems/C1) is that here, the length of each output codeword may be at most 10.**2 3Morse code is a classic way to send messages, where each letter in an alphabet is substituted with a *codeword*: a unique sequence of dots and dashes. However, ignoring spaces, it's possible for a coded message to have multiple meanings. For example, "`.....--.-.-.-..-.-.-...-.--.`" can be interpreted as either "`HACKER CUP`" or "`SEE META RENT A VAN`":4 5{{PHOTO_ID:569216148234749|WIDTH:700}}6 7Beyond Morse code, a general set of codewords is an *unambiguous encoding* if any possible sequence of dots and dashes corresponds to either zero or exactly one sequence of codewords.8 9Given one codeword \(C_1\) from a set of \(N\) distinct codewords, your task is to generate another \(N - 1\) codewords \(C_2, ..., C_N\) to yield an unambiguous encoding. It can be shown that an answer always exists. If there are multiple answers, you may print any one of them.10 11 12# Constraints13 14\(1 \le T \le 95\)15\(2 \le N \le 100\)16The length of \(C_1\) is between \(1\) and \(100\), inclusive.17The length of each \(C_2, ..., C_N\) must be between \(1\) and \(\mathbf{10}\), inclusive.18 19 20# Input Format21 22Input begins with an integer \(T\), the number of test cases. For each case, there is first a line containing a single integer \(N\). Then, there is a line containing the codeword \(C_1\).23 24 25# Output Format26 27For the \(i\)th case, output a line containing only "`Case #i:`", followed by \(N - 1\) lines, the codewords \(C_2, ..., C_N\), one per line.28 29 30# Sample Explanation31 32In the first case, it can be shown that the codewords {"`.-.`", "`...`", "`---`"} are an unambiguous encoding. Any sequence of dots and dashes can be interpreted if and only if it has a length that's a multiple of 3, and can be broken up into instances of the three length-3 codewords.33 34In the second case, it can be shown that the codewords {"`-`", "`...`", "`.-`", "`..-`"} are an unambiguous encoding. For instance, "`..`" has no possible interpretation, and "`.-...--`" can only be interpreted as "`.- ... - -`".35 36In the third case, it can be shown that the codewords {"`..`", "`-`", "`.-`"} are an unambiguous encoding. For any sequence of dots and dashes:37- every odd group of dots followed by a dash can only be interpreted as repeated "`..`"s followed by a final "`.-`"38- every even group of dots followed by a dash can only be interpreted as repeated "`..`"s followed by a final "`-`"39- every group of dots not followed by a dash (i.e. at the end of the sequence), is interpretable if and only if there is an even number of dots40- this leaves only groups of dashes, interpreted only as repeated "`-`"s41 