Introduction to Mo's Algorithm

The Mo's algorithm was proposed by Mo Tao. Before Mo Tao proposed the algorithm, it had been circulating in a small circle among top competitors on Codeforces. However, Mo Tao was the first to provide a detailed summary and systematization of the algorithm. When Mo Tao introduced the algorithm, he only analyzed the basic version, but through the collective wisdom of OIers and ACMers, Mo's algorithm has been extended into multiple variants.

Mo's algorithm can solve a class of offline interval query problems with extremely wide applicability. By extending it, it can also easily handle path queries on trees and support modification operations.