Editorial for CTU Open Contest 2018 - Escalators
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.
- Split the problem into instances by bits.
- In iteration, consider only nodes which have on the bit.
- Find sizes of components of ones (DFS).
- Each component adds .
Complexity
Comments