Text from the official booklet. Refer to the PDF for original mathematical notation, formatting, and linked input files. Printed samples and inputs are reproduced as published.
A historian is documenting an intergalactic battle by recording successful attacks in a string of letters. Each attack is represented by a unique uppercase character corresponding to the alien species that executed it (e.g., ’A’ for Antennaeters, ’B’ for Borgons). The battle is divided into multiple smaller wars, each consisting of exactlyn consec- utive attacks. For each small war, the winner is the alien species with the highest number of successful attacks (highest frequency). If there is a tie within a war, the species whose letter appears earlier in the alphabet wins. The historian wants to determine the overall battle winner — the species that has won the most small wars. If there is a tie, output the alphabetically earlier letter. Input format: First line: Two integers b (total number of attacks) and n (attacks per small war) Second line: String s of length b, containing only uppercase letters Constraints: 1 ≤ n ≤ b ≤ 105, b%n = 0 Output format: A single uppercase character representing the overall winner Sample Input: 12 4 AABBCCCCAAAB Sample Output: A Question Input: 600 30 XYZZAABBCCDDEFFGGHHIIJJKKLLMMNNOOXYZZAABBCCDDEFFGGHHIIJJKKLLMMNNOOXYZ ZAABBCCDDEFFGGHHIIJJKKLLMMNNOOXYZZAABBCCDDEFFGGHHIIJJKKLLMMNNOOXYZZAA BBCCDDEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZBBAACCDDEEGGFFHHIIJJ KKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTU UVVWWXXYYZZAABBDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZAABBCCEE FFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZAABBCCDDFFGGHHIIJJKKLLMMNNO OPPQQRRSSTTUUVVWWXXYYZZAABBCCDDEEGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXX YYZZAABBCCDDEEFFHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZAABBCCDDEEFFGGI IJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYYZZAABBCCDDEEFFGGHJJKKLLMMNNOOPPQQRRS STTUUVVWWXXYYZZ