Introduction to Mo's Algorithm

Mo's algorithm was proposed by Mo Tao. Before Mo Tao proposed it, Mo's algorithm had already circulated on a small scale among Codeforces experts, but Mo Tao was the first to systematically summarize it. When Mo Tao proposed it, he analyzed only the ordinary version; through the collective efforts of OIers and ACMers, Mo's algorithm gained several extended versions.

Mo's algorithm can solve a class of offline range-query problems and is extremely versatile. With suitable extensions, it can also handle path queries on trees and support modifications with ease.

This content comes from OI Wiki: Introduction to Mo's Algorithm. See the original for authors and revision history. AIOJ has adapted the formatting, in-site links, and resource paths.

Content is shared under CC BY-SA 4.0 and SATA license; additional terms are governed by the original notice. Thanks to the OI Wiki authors and contributors; per the SATA terms, please visit the OI Wiki repository and star it to show your support.