Problem 3193 · Hard

Count the Number of Inversions

Build permutations one position at a time, tracking how many inversions each prefix has and zeroing counts that break a requirement.

Open the interactive visualisation