MathLabs

Competition mathematics and problem solving

Olympiad combinatorics

Competition problems on counting, coloring and combinatorial games, solved with clever constructions.

IntuitionCounting the same thing two ways

Imagine a school dance where every student either dances with a partner or stands alone. If you count "number of dancing pairs times two" you get the same total as counting "how many students are dancing" — because each pair contributes exactly one dancer to each side. This trick, counting one set of objects in two different ways and setting the two counts equal, is called double counting, and it is one of the sharpest tools in olympiad combinatorics: instead of building an explicit formula, you find two honest descriptions of the same quantity and read off an identity or an inequality for free.

Network diagram of a bipartite graph on 10 vertices split into two groups of 5, with every edge crossing between the groups and none within a group.
A bipartite network on 10 vertices split into two groups of 5: every edge crosses between the groups, so no three vertices can ever form a triangle, and the edge count sits exactly at the Mantel bound 2525.

SchoolDouble counting and the handshake lemma

Definition: Double counting

A double counting argument computes the size of one set (often a set of pairs, or incidences between two kinds of objects) in two different ways, then equates the two expressions. In a graph G=(V,E)G=(V,E), the classic instance counts the set of "vertex-edge incidences" (pairs (v,e)(v,e) with vv an endpoint of ee): each edge contributes exactly 2 incidences, while each vertex vv contributes deg⁡(v)\deg(v) incidences.

∑v∈Vdeg⁡(v)=2∣E∣\sum_{v \in V} \deg(v) = 2|E|

Here VV is the vertex set, EE the edge set, and deg⁡(v)\deg(v) the number of edges touching vertex vv. The left side counts incidences vertex-by-vertex; the right side counts the same incidences edge-by-edge (2 per edge). Because both sides count the exact same set, an immediate corollary is that the number of odd-degree vertices is always even — a fact used constantly in olympiad graph problems.

∑k=0n(nk)2=(2nn)\sum_{k=0}^n \binom{n}{k}^2 = \binom{2n}{n}

This second identity comes from counting, in two ways, the number of ways to choose nn people from a group of nn boys and nn girls (proved in full below): directly it is (2nn)\binom{2n}{n}, and by splitting on how many boys are chosen it is ∑k=0n(nk)2\sum_{k=0}^n \binom{n}{k}^2. The same two-ways-of-counting mindset also drives extremal questions: instead of counting an exact quantity, we bound it from above by comparing two ways of counting a related structure, as in Turán-type theorems below.

Three core techniques in olympiad combinatorics
TechniqueCore ideaExample use
Double countingCount the same set two different ways and equate the results∑k=0n(nk)2=(2nn)\sum_{k=0}^n \binom{n}{k}^2 = \binom{2n}{n}
Turán-type extremal boundBound how many edges/sets can avoid a forbidden substructuree(G)≤⌊n2/4⌋e(G) \le \lfloor n^2/4 \rfloor for triangle-free GG
Combinatorial NullstellensatzA nonzero coefficient in a cleverly built polynomial forces a nonzero point on a gridProving existence of a zero-sum or rainbow substructure

UndergraduateTwo cornerstone theorems

If a graph GG on nn vertices contains no triangle (K3K_3), then e(G)≤⌊n2/4⌋e(G) \le \lfloor n^2/4 \rfloor, and this bound is achieved exactly by the complete bipartite graph with parts of size ⌊n/2⌋\lfloor n/2 \rfloor and ⌈n/2⌉\lceil n/2 \rceil.

Why is it true?

A triangle-free graph cannot let two adjacent vertices share a common neighbor, so their combined degree is tightly capped by nn; splitting the vertices into two roughly equal groups and connecting every cross pair saturates this cap everywhere at once, which is why the balanced complete bipartite graph is the extremal example.

Proof

We induct on nn. For n≤2n \le 2 the claim is trivial since ⌊n2/4⌋≥0\lfloor n^2/4 \rfloor \ge 0 and any graph on at most 2 vertices has at most 1 edge.

Suppose the statement holds for all triangle-free graphs on fewer than nn vertices, and let GG be triangle-free on nn vertices. If GG has no edges the bound holds trivially, so assume GG has an edge uvuv. Since GG is triangle-free, uu and vv have no common neighbor, i.e. N(u)∩N(v)=∅N(u) \cap N(v) = \varnothing.

Because N(u)N(u) and N(v)N(v) are disjoint subsets of the nn-vertex set, deg⁡(u)+deg⁡(v)=∣N(u)∣+∣N(v)∣=∣N(u)∪N(v)∣≤n\deg(u)+\deg(v) = |N(u)|+|N(v)| = |N(u) \cup N(v)| \le n.

Remove uu and vv from GG to get a triangle-free graph G′G' on n−2n-2 vertices. Every edge of GG is either the edge uvuv, an edge from uu or vv to the rest, or an edge of G′G'; counting carefully, e(G)=e(G′)+deg⁡(u)+deg⁡(v)−1e(G) = e(G') + \deg(u) + \deg(v) - 1 (the −1-1 corrects for the edge uvuv being counted once inside deg⁡(u)+deg⁡(v)\deg(u)+\deg(v) but it is not an edge of G′G').

By the induction hypothesis e(G′)≤⌊(n−2)2/4⌋e(G') \le \lfloor (n-2)^2/4 \rfloor, so e(G)≤⌊(n−2)2/4⌋+n−1e(G) \le \lfloor (n-2)^2/4 \rfloor + n - 1. A direct computation gives (n−2)2/4+n−1=n2/4−n+1+n−1=n2/4(n-2)^2/4 + n - 1 = n^2/4 - n + 1 + n - 1 = n^2/4, and checking the even/odd cases of nn separately shows ⌊(n−2)2/4⌋+n−1≤⌊n2/4⌋\lfloor (n-2)^2/4 \rfloor + n - 1 \le \lfloor n^2/4 \rfloor exactly. Hence e(G)≤⌊n2/4⌋e(G) \le \lfloor n^2/4 \rfloor, completing the induction.

For the extremal case, the complete bipartite graph with parts of size ⌊n/2⌋\lfloor n/2 \rfloor and ⌈n/2⌉\lceil n/2 \rceil has no triangle (any triangle would need an edge inside one part, but there are none) and has exactly ⌊n/2⌋⋅⌈n/2⌉=⌊n2/4⌋\lfloor n/2 \rfloor \cdot \lceil n/2 \rceil = \lfloor n^2/4 \rfloor edges, so the bound is tight.

For every integer n≥0n \ge 0, ∑k=0n(nk)2=(2nn)\sum_{k=0}^{n} \binom{n}{k}^2 = \binom{2n}{n}.

Why is it true?

Both sides count the same thing — the number of ways to pick nn people out of 2n2n — so no algebraic manipulation of binomial coefficients is needed at all, only a careful description of one selection process in two different orders.

Proof

Consider a set of 2n2n people consisting of nn boys and nn girls. We count, in two ways, the number of ways to choose a committee of exactly nn people from this set of 2n2n.

Directly, by definition, this number is (2nn)\binom{2n}{n}, since we are simply choosing nn objects out of 2n2n.

Alternatively, split every valid committee according to how many boys it contains. If the committee contains exactly kk boys for some kk with 0≤k≤n0 \le k \le n, then those kk boys can be chosen in (nk)\binom{n}{k} ways, and the remaining n−kn-k committee members must be girls, chosen from the nn girls in (nn−k)\binom{n}{n-k} ways. By the symmetry identity (nn−k)=(nk)\binom{n}{n-k} = \binom{n}{k}, the number of committees with exactly kk boys is (nk)⋅(nk)=(nk)2\binom{n}{k} \cdot \binom{n}{k} = \binom{n}{k}^2.

Every valid committee of nn people has some well-defined number of boys kk between 00 and nn, and no committee is counted twice across different values of kk, so summing over all kk gives the total number of committees as ∑k=0n(nk)2\sum_{k=0}^{n} \binom{n}{k}^2.

Since both expressions count exactly the same set of committees, they must be equal: ∑k=0n(nk)2=(2nn)\sum_{k=0}^{n} \binom{n}{k}^2 = \binom{2n}{n}.

UndergraduateReal-World Applications and Worked Examples

Double counting and extremal graph bounds are not just competition tricks: network engineers use handshake-lemma-style degree arguments to check the feasibility of a proposed connection topology before laying cable, and Turán-type triangle-free bounds appear in the design of interference-free wireless channel assignments (two transmitters that would create a triangle of mutual interference cannot all be simultaneously active). The two worked examples below show the double-counting and extremal-bound techniques in concrete competition settings.

Example: The handshake parity puzzle

At a conference of 2525 people, some pairs shake hands (each pair at most once). Prove that the number of people who shook hands an odd number of times is even.

Solution

Model the people as vertices of a graph GG, and draw an edge between two people exactly when they shook hands; then the number of handshakes person vv made is deg⁡(v)\deg(v).

By the handshake lemma, ∑vdeg⁡(v)=2∣E∣\sum_{v} \deg(v) = 2|E|, which is an even number regardless of how many handshakes occurred.

Split the sum into people with even degree and people with odd degree: ∑vdeg⁡(v)=∑deg⁡(v) evendeg⁡(v)+∑deg⁡(v) odddeg⁡(v)\sum_{v} \deg(v) = \sum_{\deg(v)\text{ even}} \deg(v) + \sum_{\deg(v)\text{ odd}} \deg(v). The first sum is a sum of even numbers, hence even.

Since the total sum is even and the first partial sum is even, the second partial sum (sum of odd degrees) must also be even. But a sum of odd numbers is even only if there is an even number of terms, so the number of people with odd degree — the number of people who shook hands an odd number of times — must be even.

Example: Maximum interference-free channel graph on 9 stations

A wireless network has 99 stations; a link between two stations is allowed only if it creates no triangle of mutual interference (no 33 stations pairwise linked). What is the maximum possible number of links, and which layout achieves it?

Solution

The condition "no triangle of mutual interference" is exactly the triangle-free condition of Mantel's theorem with n=9n=9 stations, so the maximum number of links is ⌊92/4⌋=⌊81/4⌋=20\lfloor 9^2/4 \rfloor = \lfloor 81/4 \rfloor = 20.

To achieve this bound, split the 99 stations into two groups of sizes 44 and 55, and link every pair of stations that are in different groups (a complete bipartite layout K4,5K_{4,5}), while allowing no links within a group.

This layout has no triangle, because any triangle would require an edge between two stations in the same group, and there are none. The number of links is exactly 4×5=204 \times 5 = 20, matching the bound from Mantel's theorem, so this is optimal.

By Mantel's theorem, a triangle-free graph on 1010 vertices has at most how many edges?

At a party of 1515 people, some pairs shake hands. By the handshake lemma, which of the following could NOT be the number of people who shook hands an odd number of times?

Using a double-counting argument (choosing nn people from nn boys and nn girls), the sum ∑k=0n(nk)2\sum_{k=0}^n \binom{n}{k}^2 equals which closed form?

Combinatorial Nullstellensatz is most directly useful for competition problems that ask you to show a combinatorial structure exists by proving:

References

  1. Noga Alon (1999). Combinatorial Nullstellensatz
  2. Béla Bollobás (1998). Modern Graph Theory
  3. Titu Andreescu, Zuming Feng (2003). 102 Combinatorial Problems