Editorial for CCC '24 S2 - Heavy-Light Composition
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
Hard-code every possible string containing "a" and "b" of length between
Subtask 2
There was no intended solution for this subtask. It was intended to allow for possibly slower full solutions.
Subtask 3
We consider two cases for if it starts with "a" or not:
- Check that every second letter is "a" and that the rest are not "a".
- Check that every second letter is not "a" and that the rest are "a".
If either case is true, output T
; otherwise, output F
.
Subtask 4
First, create an array that will store the frequency of each letter in the string. Each element represents the count of a particular letter. Then, iterate over all letters in the string and increment the frequency of it in the array.
We realize we can extend the logic from subtask 3 with this array. If a letter has a frequency greater than
We consider two cases for if it starts with a heavy letter or not:
- Check that every second letter has a frequency greater than
and that the rest are light. - Check that every second letter does not have a frequency greater than
and that the rest are heavy.
If either case is true, output T
; otherwise, output F
.
Comments