Pattern · CP 1600
Constructive Algorithms
Prove when an object (array, permutation, grid, graph) exists, and build it directly. Usually: solve tiny cases by hand, spot the pattern, and handle a few parity or size cases.
Learn firstGreedyMath / Number Theory
0%
mastery
0/9 solved
0/9 solved
Recognise it
The signal
'output any array/permutation/grid that satisfies ... or -1'
1Brute force
Backtracking over all objects (n! or 2n).
2The observation
The search space. The trick is a structural insight.
3Why it works
The construction keeps a property that implies validity (e.g. each block adds exactly one to the LIS).
Reach for it when
- +existence depends on n mod 2/3/4
- +construct with exactly k inversions / a given LIS length / given degrees
Not when
- ×the answer must be optimal among many candidates (DP / greedy proofs)
- ×n is tiny (backtracking is fine)
Practice
0/9 solved
- PermutationsCSESEasy
- Inverse InversionsCSESMedium
- Monotone SubsequencesCSESMedium
- Chess TournamentCSESMedium
- Gray CodeCSESMedium
- Special PermutationCodeforces1600
- Beautiful Arrangement IIMedium
- Gray CodeMedium
- Third PermutationCSESHard
Pitfalls
Misconceptions
- !skipping the brute force on small n that shows the pattern and the -1 cases