Editorial for JDCC '15 Contest 4 P2 - Ants on a Log
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.
Author:
Ants are indistinguishable. Thus, when they collide and turn back, the state is the same as no collision: the ants walking through each other. Using this trick, just find the longest distance that an ant walks.
Time Complexity: , is the number of ants.
Comments