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
Suppose the answers for
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
These observations are enough to generate the answer for any power of
Subtask 2
Note that
This subtask requires deeper observations about Alice's filters.
Property 1 (Filters are symmetric). If
Property 2 (The
The proof of these 2 properties is left as an exercise. From these properties, it becomes natural to define the function
Theorem 1. If
Proof. Apply Property 1 and Property 2.
Theorem 2. Suppose
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
Alternatively, it is enough to ignore cycle detection and construct the first
Subtask 3
Note that
Firstly, use the first
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
Comments