This content is archived!
For the 2018-2019 school year, we have switched to using the WLMOJ judge for all MCPT related content. This is an archive of our old website and will not be updated.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
\mathcal{O}(N), N is the number of ants.