Skip to content

CF1286C2 Madhouse

Step 1

We essentially get a (multi)set containing all sets of substrings of \(s[l, r]\). And we have only 3 queries. There is also limitation on the sum of subset count.


This is after the solution has been revealed.

We can first try to use set difference to find the answer. We can query \([1, n]\) and \([1, n - 1]\) and differentiate to get the suffix lengths.

But this approach violates the subset count. we can query \([1, mid - 1]\) \([1, mid]\) \([1, n]\). We can use the same method as before to find everything in \([1, mid]\). Then we can build the prefixes from \(mid\) from the last query. (TO BE CLARIFIED AND UNDERSTOOD)