Editorial for CTU Open Contest 2018 - Locker Room
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
- Create Suffix array over .
- Binary search by answer
- Scratch out every segment with lesser rank.
- Scratching can be done with sweep.
- Total complexity .
- Keep track of non-scratched segments
- Traverse SA and remove scratched segments.
- Segments in Set:
- Total complexity .
- Note that complexity depends on SA construction. suffices (if implemented reasonably).
Comments