Constructive Algorithms

Parity arguments, invariants, greedy constructions, and reverse simulation through 10 problems.

37 lessons
126 min

Lessons

1. Introduction to Constructive Algorithms

Building valid solutions from constraints

2m

2. Techniques Overview

What you'll learn

3m

3. Codeforces 1375D Replace by MEX - Problem Statement

CF 1375D - transform array using MEX operations

3m1 problems

4. Codeforces 1375D Replace by MEX - Why Naive Fails

Random operations don't converge

3m

5. Codeforces 1375D Replace by MEX - Solution

Fix positions using MEX cycles

3m

6. Codeforces 1375D Replace by MEX - Implementation

Greedy MEX placement

5m1 problems

7. Codeforces 1375D Replace by MEX - Example and Complexity Analysis

Quadratic in array size

3m

8. Codeforces 1450C1 Errich-Tac-Toe - Problem Statement

CF 1450C1 - modify grid to avoid wins

3m1 problems

9. Codeforces 1450C1 Errich-Tac-Toe - Solution

Change one color class

3m

10. Codeforces 1450C1 Errich-Tac-Toe - Implementation

Color class transformation

5m1 problems

11. Codeforces 1450C1 Errich-Tac-Toe - Example and Complexity Analysis

Linear in grid size

3m

12. Codeforces 1485D Multiples and Power Differences - Problem Statement

CF 1485D - construct grid with divisibility

3m1 problems

13. Codeforces 1485D Multiples and Power Differences - Solution

LCM checkerboard

3m

14. Codeforces 1485D Multiples and Power Differences - Implementation

LCM-based checkerboard

5m1 problems

15. Codeforces 1485D Multiples and Power Differences - Example and Complexity Analysis

Linear construction

3m

16. Codeforces 1559D1 Mocha and Diana - Problem Statement

CF 1559D1 - add edges to two forests simultaneously

3m1 problems

17. Codeforces 1559D1 Mocha and Diana - Solution

Greedy with dual DSU

3m

18. Codeforces 1559D1 Mocha and Diana - Implementation

Dual DSU edge selection

5m1 problems

19. Codeforces 1559D1 Mocha and Diana - Example and Complexity Analysis

Quadratic pair iteration

3m

20. Codeforces 1605D Treelabeling - Problem Statement

CF 1605D - label tree to control XOR traversal

3m1 problems

21. Codeforces 1605D Treelabeling - Why Naive Fails

Exponential labelings

3m

22. Treelabeling - Key Insight

Group numbers by highest bit

3m

23. Codeforces 1605D Treelabeling - Solution

Bipartite coloring by bit groups

3m

24. Codeforces 1605D Treelabeling - Implementation

Bipartite assignment by bit

5m1 problems

25. Codeforces 1605D Treelabeling - Example and Complexity Analysis

Linear tree traversal

3m

26. Codeforces 1572B Xor of 3 - Problem Statement

CF 1572B - make array all zeros with XOR operations

3m1 problems

27. Codeforces 1572B Xor of 3 - Why Naive Fails

Search space is huge

3m

28. Codeforces 1572B Xor of 3 - Solution

Parity and greedy zeroing

3m

29. Codeforces 1572B Xor of 3 - Implementation

Check invariant and construct

5m1 problems

30. Codeforces 1572B Xor of 3 - Example and Complexity Analysis

Linear construction

3m

31. Codeforces 1638D Big Brush - Problem Statement

CF 1638D - reconstruct painting sequence

3m1 problems

32. Codeforces 1638D Big Brush - Why Naive Fails

Forward simulation has too many choices

3m

33. Codeforces 1638D Big Brush - Solution

Reverse greedy with queue

3m

34. Codeforces 1638D Big Brush - Implementation

BFS-style reverse simulation

5m1 problems

35. Codeforces 1638D Big Brush - Example and Complexity Analysis

Linear in grid size

3m

36. Quiz: Constructive Algorithms

Test your understanding

5m1 problems

37. Section Recap

What you've learned

3m

Ready to start learning?

Access all 37 lessons with interactive content and progress tracking.