Editorial for CCC '23 S5 - The Filter
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
The answers for are .
Suppose the answers for are . The answers for the first third of are
The Cantor set has copies of the same structure. In particular, the first third of the Cantor set is identical to the last third. The remaining answers for are
These observations are enough to generate the answer for any power of .
Subtask 2
Note that is covered by the filter, but not any earlier filter. This is the maximum record for . A naive approach is expected to fail on .
This subtask requires deeper observations about Alice's filters.
Property 1 (Filters are symmetric). If is covered by the -th filter, then is covered by the -th filter. Likewise, if the -th filter does not cover , then is not covered by the -th filter.
Property 2 (The -th filter and -th filter are related). Let be a positive integer, and let . If is covered by the -th filter, then is covered by the -th filter. Likewise, if is not covered by the -th filter, then is not covered by the -th filter.
The proof of these 2 properties is left as an exercise. From these properties, it becomes natural to define the function . Here are a few theorems about .
Theorem 1. If is not covered by any filter, then is not covered by any filter.
Proof. Apply Property 1 and Property 2.
Theorem 2. Suppose is covered by the -th filter. Then either , or is covered by the -th filter.
Proof. Apply Property 1 and Property 2.
Here is the approach to solving subtask 2:
- Let . Construct this sequence:
- If is in the Cantor set, then by Theorem 1, every term in the sequence is in the Cantor set. Since every term is a multiple of , the sequence will enter a cycle.
- If is not in the Cantor set, then is covered by a filter. By Theorem 2, a term in the sequence will be covered by the first filter.
There are 2 outcomes. Either the sequence will enter a cycle, or a term will be covered by the first filter. The algorithm needs to handle both outcomes. The intended total time complexity is or slightly slower.
Alternatively, it is enough to ignore cycle detection and construct the first terms. In the worst case (i.e. ), the term is covered by the first filter.
Subtask 3
Note that is covered by the filter, but not any earlier filter. The author believes this is the maximum record for .
Firstly, use the first filters to remove most of the numbers. After this step, less than numbers remain.
Next, apply the algorithm from subtask 2 on each of the remaining numbers. It may be a good idea to use memoization to improve time complexity. There are other tricks to improve performance.
The intended time complexity is because there are numbers to consider, and each number takes roughly to consider. Note: The exponent is exactly .
Comments