Divide & Conquer - DP

Authors: Andi Qu, Benjamin Qi

Using Divide & Conquer as a DP Optimization.

Allows you to reduce to .


Example - Circular Barn

Focus Problem – read through this problem before continuing!

You should already be familiar with the CHT solution.

This section is not complete.

Any help would be appreciated! Just submit a Pull Request on Github.

Add analysis later.

Check the official editorial.


StatusSourceProblem NameDifficultyTagsSolutionURL
CEOINormalView Solution
COINormalExternal Sol
CFHardCheck CF
CFHardCheck CF
POIVery HardView Solution
IOIVery HardExternal Sol
PlatVery HardExternal Sol
JOIVery Hard

JOI Bubblesort English Statement: You are given an array of length . You must choose two numbers in this array and swap them. After swapping these two numbers, you sort the array using a bubble sort algorithm. What is the minimum number of bubble sort swaps necessary, assuming you choose the two initial numbers to swap optimally? The two initial numbers that you swap do not count towards the minimum number of bubble sort swaps.

Module Progress:

Join the USACO Forum!

Stuck on a problem, or don't understand a module? Join the USACO Forum and get help from other competitive programmers!

Give Us Feedback on Divide & Conquer - DP!

Leave suggestions for us by making a post on the USACO Forum! Ex: Unclear sections, mislabeled problems, etc.