Library · Between the Challenge and the Olympiad · Chapter 11
Sets, Inclusion-Exclusion and Configurations
On this page
- Problems
- Solutions
- Solution: IOQM 2026, Q1
- Solution: IOQM 2026, Q12
- Solution: IOQM 2024, Q9
- Solution: IOQM 2025 Part SEP, Q7
- Solution: IOQM 2025 Part SEP, Q28
- Solution: IOQM 2026, Q17
- Solution: PRMO 2017, Q22
- Solution: PRMO 2019, Q27
- Solution: IOQM 2020, Q15
- Solution: IOQM 2021 Part A, Q11
- Solution: IOQM 2023, Q16
- Solution: IOQM 2024, Q19
- Solution: IOQM 2026, Q26
- Solution: PRMO 2018, Q26
- Solution: IOQM 2020, Q27
- Solution: IOQM 2023, Q18
Problems
Problem 1
The central square of a chessboard is white. How many white squares are there on the board? (The squares of the chessboard are coloured alternately black and white.)
Problem 2
A board is divided into unit squares. We place checkers on the board, at most one per square. Find the largest number of checkers that can be placed on the unit squares so that each row, as well as each column, contains an even number of checkers.
Problem 3
Consider the grid of points . We say a pair of points in is a knight-move pair if ( and ) or ( and ). The number of knight-move pairs in is:
Problem 4
A quadrilateral has four vertices . We want to colour each vertex in one of the four colours red, blue, green or yellow, so that every side of the quadrilateral and the diagonal have end points of different colours. In how many ways can we do this?
Problem 5
Consider a rectangle made of 6 unit squares. In how many ways can we fill up the six cells using the numbers , one in each cell, such that any two numbers in adjacent cells (that is, in cells that share a common side) are coprime to each other?
Problem 6
There are six coupons numbered 1 to 6 and six envelopes, also numbered 1 to 6. The first two coupons are placed together in any one envelope. Similarly, the third and the fourth are placed together in a different envelope, and the last two are placed together in yet another different envelope. How many ways can this be done if no coupon is placed in the envelope having the same number as the coupon?
Problem 7
Find the number of ordered triples of positive integers such that and
Problem 8
Suppose in the plane 10 pairwise nonparallel lines intersect one another. What is the maximum possible number of polygons (with finite areas) that can be formed?
Problem 9
We will say that a rearrangement of the letters of a word has no fixed letters if, when the rearrangement is placed directly below the word, no column has the same letter repeated. For instance, is a rearrangement with no fixed letters of . How many distinguishable rearrangements with no fixed letters does have? (The two s are considered identical.)
Problem 10
Three couples sit for a photograph in 2 rows of three people each such that no couple is sitting in the same row next to each other or in the same column one behind the other. How many arrangements are possible?
Problem 11
In how many ways can four married couples sit in a merry-go-round with identical seats such that men and women occupy alternate seats and no husband seats next to his wife?
Problem 12
The six sides of a convex hexagon are coloured red. Each of the diagonals of the hexagon is coloured either red or blue. If is the number of colourings such that every triangle , where , has at least one red side, find the sum of the squares of the digits of .
Problem 13
Consider five points in the plane, with no three of them collinear. Every pair of points among them is joined by a line. In how many ways can we colour these lines by red or blue, so that no three of the points form a triangle with lines of the same colour.
Problem 14
Three girls , each read four stories and discuss which ones they like. No story is liked by all the three. For each of the three pairs of the girls, there is at least one story which is liked by the pair and not liked by the third. Let be the number of ways in which this is possible. Find the sum of the squares of the digits of .
Problem 15
There are points in the plane, no three of which are collinear. Every pair of points is joined by a segment which is coloured red or blue such that the following conditions hold:
(a) If are three points such that is red and is blue, then is red.
(b) For any point , there are exactly three points such that , , are red.
Find the sum of all possible values of .
Problem 16
What is the number of ways in which one can choose unit squares from a chessboard such that no two chosen squares have a side in common?
Problem 17
A bug travels in the coordinate plane moving only along the lines that are parallel to the axis or axis. Let and . Consider all possible paths of the bug from to of length at most 14. How many points with integer coordinates lie on at least one of these paths?
Problem 18
Let be a convex polygon with 50 vertices. A set of diagonals of is said to be minimally friendly if any diagonal intersects at most one other diagonal in at a point interior to . Find the largest possible number of elements in a minimally friendly set .
Problem 19
For how many numbers in the set can we split the numbers into pairs , such that is a square?
Solutions
Solution: IOQM 2026, Q1
On a board with an odd number of squares a side, the colour of the centre is the colour of the corners, and that is the colour with one square to spare.
Number the rows and the columns from to . Moving one square along a row or a column changes the colour and changes the sum of the two coordinates by one, so two squares share a colour exactly when their coordinate sums have the same parity. The centre is , with an even sum, so the white squares are those whose row and column numbers are both odd or both even.
Both odd: five choices of row and five of column, squares. Both even: four and four, squares. The number of white squares is against black ones, so white is the colour with the square to spare.
Answer 41
Solution: IOQM 2026, Q12
Seven is odd, so a row holding an even number of checkers has at least one empty square, and leaving one diagonal empty meets that bound in every row and every column at once.
Each row has seven squares and must hold an even number of checkers, so it holds at most six. The seven rows together hold at most
Leave the seven squares of a diagonal empty and fill the other . The diagonal meets every row once and every column once, so each row and each column has exactly six checkers, which is even. The largest number is .
Answer 42
Solution: IOQM 2024, Q9
Count by the shape of the move rather than by the square it starts from: each of the four displacement types fits into the grid in the same number of ways.
A knight-move pair is a pair of points differing by one of the vectors Since a pair is unordered, we may fix the sign of the first coordinate and count the four displacement types
Take . Its starting point needs so that , and so that , giving placements. Each of the other three types is a reflection of this one in a grid symmetry, so each also has placements.
Hence the number of knight-move pairs is .
Answer 48
Solution: IOQM 2025 Part SEP, Q7
The constraints make and two triangles glued along , so colour and first and then and independently.
The pairs required to differ are , , , and . Read that as two triangles, and , sharing the edge .
Colour first, in ways. Then must differ from , giving ways. Now must differ from both and , which are already different, so ways; and must likewise differ from and , another ways, with no constraint between and since is the diagonal that was left free.
Hence the count is .
Answer 48
Solution: IOQM 2025 Part SEP, Q28
The three even numbers are pairwise not coprime, so they must occupy one of the two chequerboard classes of the board, and the only remaining condition is that and are not adjacent.
Among the pairs that are not coprime are So , and must pairwise occupy non-adjacent cells, and additionally must not sit next to .
Colour the board like a chessboard. The two colour classes are and these are the only three-cell sets with no two cells adjacent. Indeed the two cells of a column are adjacent, so no column holds two chosen cells, and three cells in three columns then means exactly one per column; consecutive columns must use opposite rows, or their cells would be side by side, so the rows alternate and the set is one of the two above. So fill one class and the other, giving arrangements before the last condition.
Now remove those with next to . Fix the class holding the evens, place , and count. In either class one cell has three neighbours in the other class and the other two cells have two each. With on a cell of degree , the number of bad arrangements is so the bad total for one class is out of its arrangements, leaving . The other class behaves identically, so the answer is
Answer 16
Solution: IOQM 2025 Part SEP, Q7
Each pair of coupons has four allowed envelopes, and the only extra work is removing the cases where two pairs land in the same envelope, which can happen in just one envelope-pair at a time.
The pair may go into any envelope except and , so choices; likewise avoids envelopes and , and avoids and . Ignoring the requirement that the three envelopes be different, that is ways.
Now remove the clashes. If the pairs and share an envelope, that envelope must avoid , so it is or : two choices, and the third pair still has its , giving cases. The same count applies to each of the other two coincidences, by the same reasoning with the labels shifted. All three pairs in one envelope is impossible, since no envelope avoids all six numbers.
By inclusion and exclusion the number of assignments with all three envelopes distinct is
Answer 40
Solution: IOQM 2026, Q17
For three numbers the three distances between them add up to twice the gap between the largest and the smallest, so the condition says only that the triple spans a range of .
Put the three values in order as . Whatever order , , take them in, the three distances are , and , whose sum is So the condition is : the largest and the smallest values differ by exactly .
The smallest value has , so is one of . With fixed, the triple takes values in and must use both ends. Of the ordered triples in that range, miss and miss , and miss both, so by inclusion and exclusion use both ends. Four choices of give triples.
Answer 96
Solution: PRMO 2017, Q22
Ten lines in general position bound regions, but a “polygon with finite area” need not be a single region, and counting every polygon whose sides lie along the lines gives a completely different number.
This question was discounted by the organisers, and the ambiguity is in the word polygons.
Under the first reading, a polygon means one of the regions into which the lines cut the plane. Three lines in general position form seven regions, just one of them bounded. On adding a fourth line, its three distinct intersections split it into four pieces, each of which splits an old region in two. The new total is therefore eleven. In general, line meets the previous lines in distinct points and adds regions. Starting from one region with no lines, ten lines in general position, no two parallel and no three concurrent, therefore cut the plane into regions. To count the unbounded ones, draw a circle large enough to contain every intersection. Each line crosses it twice, giving distinct crossing points and arcs between them. Each arc meets exactly one unbounded region, and every unbounded region meets one arc, so there are such regions. So the number of bounded regions is which one can also write as .
Under the second reading, a polygon is any closed figure with finite area whose sides lie along the given lines, whether or not it is a single region. Then every three lines already bound a triangle, so there are at least polygons before quadrilaterals and larger figures are counted at all.
Both readings are natural, they give and something above , and the paper offers no way to choose. That is why the question carries no answer.
Answer none
Solution: PRMO 2019, Q27
Place the two identical s first, in the four positions they are allowed; whatever they take, the four distinct letters then face exactly two forbidden positions, and a two-term inclusion-exclusion counts those.
The word is , with the two s in positions and and the four distinct letters in positions . A rearrangement has no fixed letters when no position holds the letter that was originally there.
Placing the s
Neither may go into position or position , so the two of them occupy two of the four positions . Since the s are identical, that is a choice of a pair: ways.
Placing the rest
Whichever pair the s take, four positions remain for : the two of left over, and positions and . Positions and originally held , so any of the four letters may go there. The two remaining positions from each forbid exactly one letter, and the two forbidden letters are different.
So we must count the ways of matching four letters to four positions, one letter each, avoiding two specified letter-position pairs. By inclusion-exclusion,
Multiplying the two independent choices,
The reason this is so much easier than a general count of arrangements with nothing in its own place is that the repeated letter was handled first. Trying instead to run inclusion-exclusion over all six positions at once means tracking how many s have been fixed, which works but takes three times the writing.
Answer 84
Solution: IOQM 2020, Q15
Count the seatings that fail rather than the ones that succeed. There are seven forbidden seat pairs, and inclusion-exclusion over the three couples needs only two facts about those seven: how many pairs of them are disjoint, and how many triples cover all six seats.
seats and lie in three of them, the other four in two
Number the seats across the front row and across the back, with seat directly in front of seat . A couple is badly placed exactly when it occupies one of which is seven forbidden pairs. Counting the good arrangements directly means tracking three interacting restrictions at once, whereas counting the bad ones lets inclusion-exclusion do the bookkeeping. Let be the event that couple is badly placed, out of seatings.
One couple badly placed
Choose one of the seven forbidden pairs, seat that couple in it in ways, and arrange the remaining four people freely in ways, so and the first sum is .
Two couples badly placed
Now two of the seven pairs must be disjoint, since two couples cannot share a seat. The seven pairs meet the six seats with degrees respectively, so the number of pairs of forbidden pairs that share a seat is , leaving disjoint pairs. Assigning them to the two couples in ways, ordering each couple in ways, and seating the last two people in ways gives , so the second sum is .
All three couples badly placed
Here the three forbidden pairs must be disjoint and between them cover all six seats. Seat appears in only two forbidden pairs, and , so split on which one is used.
If is used, seat is left, and its only other pair is , since now clashes. Seats and remain, and is indeed forbidden, giving .
If is used, seat takes or . The first leaves seats , and is forbidden, giving . The second leaves seats , and is forbidden, giving .
Every branch closed, so there are exactly three coverings. Assigning these to the couples in ways and ordering within each couple in ways gives .
Inclusion-exclusion now yields bad seatings, so the number of acceptable arrangements is .
Answer 96
Solution: IOQM 2021 Part A, Q11
Seat the men first, which uses up the rotational freedom, and then the wives face a forbidden-position problem: each must avoid the two gaps flanking her husband.
The seats are identical, so two seatings that differ by a rotation are the same seating. The tidiest way to handle that is to place the men first and let them absorb the symmetry. Four men arranged in a circle up to rotation can be done in ways.
Once the men are down, the four women must occupy the four gaps between consecutive men, which is what makes the seats alternate. Number the men round the circle and number the gaps so that gap lies between and , indices read cyclically. Wife may not sit next to her own husband, so she is barred from gaps and , which leaves her the other two:
Two gaps each is few enough to settle by looking at . If takes gap , then gap is gone, so must take gap ; that closes gap , so must take gap ; and is left with gap . If instead takes gap , the same chain forces to gap , then to gap , then to gap . So there are exactly two seatings of the wives, and both are legal.
Multiplying the two independent choices, the number of seatings is .
Answer 12
Solution: IOQM 2023, Q16
Every triangle with a vertex-pair adjacent on the hexagon already has a red side, so the condition bites on exactly two triangles, and , and those two use up the six short diagonals between them.
Of the triangles , most are free. If two of the three chosen vertices are neighbours on the hexagon, the side joining them is a side of the hexagon, which is red, and the triangle is satisfied whatever we do. So the only triangles that impose anything are those whose three vertices are pairwise non-adjacent, and in a hexagon there are exactly two such triples,
Their sides are the six short diagonals, three for each triangle, and the two sets of three do not overlap. The hexagon’s three long diagonals , , appear in neither, so they may be coloured freely.
Counting is now immediate. Each of the two triangles must avoid being all blue, which rules out of the colourings of its three sides, leaving ; the choices for the two triangles are independent because they share no diagonal; and the three long diagonals contribute a factor . Hence and the sum of the squares of the digits is .
Answer 94
Solution: IOQM 2024, Q19
No vertex can carry three edges of one colour, so every vertex has exactly two red and two blue edges, which makes the red edges a five-cycle.
Suppose some point had three red edges, to , , . If any of , , were red it would close a red triangle with ; and if all three were blue then would be a blue triangle. Either way a monochromatic triangle appears. The same argument applies with the colours exchanged, so at each of the five points exactly two of the four edges are red and two are blue.
So the red edges form a graph on five vertices in which every vertex has degree two, that is, a disjoint union of cycles covering all five vertices. The only possibility is a single cycle of length five, since a shorter cycle would leave two or fewer vertices to carry a cycle of their own, and cycles need at least three vertices. The blue edges are then the complementary five edges, which also form a five-cycle, namely the "pentagram" of the red one.
Conversely, if the red edges form a five-cycle, no red triangle exists (a triangle would need three mutually adjacent vertices on a five-cycle) and neither does a blue one, by the same argument applied to the complementary five-cycle.
So the colourings correspond exactly to the five-cycles through the five points, and the number of these is since a cycle can be written starting from a fixed vertex in orders, and each cycle is counted twice, once in each direction.
Answer 12
Solution: IOQM 2025 Part SEP, Q28
Each story is described by the set of girls who like it, which may be any of the seven subsets other than all three, and the requirement is that three particular subsets each occur.
Describe the situation by recording, for each of the four stories, the set of girls who like it. Since no story is liked by all three girls, each story gets one of the subsets other than . Without further conditions there are possibilities.
The remaining requirement is that each of the three two-girl subsets , , is the label of at least one story, since a story liked by exactly that pair is a story liked by the pair and not by the third girl.
The requirement is that all three of those labels appear. Inclusion and exclusion applies with the three labels as the forbidden things: Evaluating, and the sum of the squares of the digits is .
Answer 14
Solution: IOQM 2026, Q26
A red neighbour of must be joined in red to every blue neighbour of , and it has only three red segments. So each point has at most two blue segments, which leaves to try.
every point has three solid segments
Every point has three red segments, so , and each point has blue ones.
Fix a point and a red neighbour of it. For every with blue, condition (a) makes red. So has red segments to and to all blue neighbours of , which is red segments. There are only three, so .
. Every segment is red, so (a) never applies, and each point has three red segments. This works.
. Each point has exactly one blue segment, so the blue segments pair off the five points, which is impossible for an odd number of points.
. Split the points into two groups of three. Colour segments inside a group blue and segments between groups red. Each point has three red segments, to the other group. If is red then and are in different groups, and if is blue then is in ’s group, so and are in different groups and is red. This works.
The possible values are and , and their sum is .
Answer 10
Solution: PRMO 2018, Q26
A row can hold at most six chosen squares, and only by taking the odd columns; the total shortfall is then just six, which pins the choice down to every plain square of the chessboard colouring, or every shaded one but a single square.
a legal sixty is all the plain, or all but one of the shaded
Two choices of sixty squares are easy to find, and between them they account for sixty-two selections. Everything after that is one long argument that there is nothing else, so it is worth knowing in advance that the target is and that the work lies entirely in the uniqueness.
Colour the board like a chessboard, calling a square black when its row and column numbers have the same parity. There are black squares and white ones, and no two squares of the same colour share a side.
Two families that work
Any of the black squares form a legal choice, which is ways. So do all white squares, for one more. The claim is that there is nothing else, making .
Rows and columns cannot do better than six
In a single row of eleven squares, no two chosen squares are adjacent, so at most six are chosen; and six is possible only by taking columns . Call a row full when it holds six. The same statement holds for columns, with rows in place of columns.
Since the eleven rows hold squares in all and no row holds more than six, the total shortfall is exactly . Every row that is not full contributes at least , so at most six rows are not full: at least five rows are full. The same argument gives at least five full columns.
Full rows and full columns have the same parity
Suppose row is full, so the chosen squares of that row sit exactly in the odd columns, and suppose column is full, so the chosen squares of that column sit exactly in the odd rows. Look at the square . The row says it is chosen exactly when is odd; the column says it is chosen exactly when is odd. So and have the same parity.
Since at least one full column exists, all full rows share its parity, and so all full rows have the same parity as each other.
The even case gives the white squares
If the full rows are even-numbered there are only five of them available, so all of are full, and likewise all of the columns . The full even rows contribute the squares (even row, odd column), the full even columns contribute the squares (odd row, even column), and these are all white and all distinct. That is already squares, so the choice is exactly the white class.
The odd case gives the black squares
Otherwise the full rows are odd-numbered. If all six odd rows are full, they contribute the squares (odd, odd). Each even row then lies between two full rows, so its squares must avoid the odd columns, leaving at most the five even columns; the five even rows therefore contribute at most , and to reach they contribute . So the choice is every black square but one.
If instead exactly five odd rows are full, then the six remaining rows, namely the five even rows and one odd row , each fall short by exactly one, so each holds five squares. Every even row still has a full odd neighbour, so it is confined to the even columns and takes all five of them, which are black. Row is odd, so its neighbours in the board are even rows, and it has at least one of them, namely row if , row if , and both otherwise. That neighbour occupies every even column, so row can use none of them: it is confined to the odd columns and takes five of those six. Again the choice is every black square but one.
The count
Every legal choice of is therefore all the white squares, or all but one of the black squares:
Answer 62
Solution: IOQM 2020, Q27
A point lies on some admissible path exactly when the detour through it is short enough, that is when . That condition separates into a statement about and a statement about .
The bug moves only horizontally and vertically, so the length of a path is measured by the taxicab distance, and the shortest route from to has length . A lattice point lies on some path from to of length at most precisely when going via costs at most , that is when and any such detour can always be realised as an actual staircase path. The parity looks after itself, since always has the same parity as .
Now write out that condition for : The two halves separate, and each is a familiar shape. The sum equals whenever lies between and , and equals outside that range, so it is . Likewise is . The condition is , and since is at least and at least there is not much room.
Work through the possible values of . When , which happens for the seven values , we need , and that allows , giving nine values of and so points. When , at , we need , allowing , which is seven values and points. When , at , we need , allowing only , which is five values and points. When we would need , which is impossible since is never less than .
The total is .
Answer 87
Solution: IOQM 2023, Q18
Removing one diagonal from each crossing pair leaves a non-crossing family, so where is the number of crossing pairs; and the crossing pairs nest inside one another in a way that forces .
Throughout, . The one fact we need first is that a set of pairwise non-crossing diagonals of a convex -gon has at most members.
Why a non-crossing family has at most members
Keep adding non-crossing diagonals until no more can be added. Every region is then a triangle, since a region with four or more vertices admits another diagonal. Say the final set has diagonals and cuts the polygon into triangles. Each diagonal, when it was drawn, split one region into two, so the number of regions rose by one each time and Now count the sides of the triangles. Each of the edges of the polygon lies on exactly one triangle, and each diagonal lies on exactly two, so Substituting gives , that is . The original set was part of this one, so it had at most diagonals.
The upper bound
Let be minimally friendly and let be the number of crossing pairs inside it. Since each diagonal meets at most one other, these pairs are disjoint: they form a matching. Delete one diagonal from each pair. What is left is pairwise non-crossing, so
It remains to bound , and this is where the structure appears. Take one crossing pair, with diagonals and meeting inside, where occur in this cyclic order. These two diagonals cut the polygon into four regions, one containing each of the four arcs , , , . Now take any other crossing pair. Neither of its diagonals may cross or , so each lies inside one of the four regions; and since the two of them cross each other, they lie in the same region. So every other crossing pair sits inside one of the four regions.
Let be the largest possible number of crossing pairs when the available vertices number , and let us show We use induction on . The claim holds for because then . For larger , if there is no crossing pair the bound is already true. Otherwise pick one crossing pair as above. Each of its four regions excludes two of the four selected endpoints, so it has at most original vertices. The induction hypothesis therefore applies inside every region. If the four regions have available vertices, then , because each of is available to two of the regions. Hence, dropping the floors on the right, The left side is a whole number, so it is at most , as claimed. With this gives , and therefore
The construction
Triangulate the -gon in a zigzag, drawing the diagonals so that the triangles form a chain, each sharing an edge with the next. That is diagonals, pairwise non-crossing.
Now pair the triangles along the chain: the first with the second, the third with the fourth, and so on, giving pairs. Each pair forms a convex quadrilateral whose two triangles share a diagonal of the triangulation. Add the other diagonal of that quadrilateral. It is a genuine diagonal of the -gon, since a quadrilateral inscribed in the polygon has two vertices strictly between the endpoints of each of its diagonals. It stays inside its own quadrilateral, so it meets no added diagonal from another pair and no triangulation diagonal other than the original shared diagonal of that quadrilateral.
The result has diagonals, each meeting at most one other, so the largest possible size is exactly
Answer 71
Solution: IOQM 2025 Part SEP, Q7
Pairing with makes the product of the pair-sums equal to , a square when is even. For odd , deal with through separately and pair the rest in the same way.
Only fails, and it fails immediately: the single pair is and the product is , not a square.
For even , pair each with . Every pair sums to , so the product of the sums is , which is a perfect square because is even.
For odd , handle the first six numbers by hand. The pairing gives sums and product . The remaining numbers are , an even block, and pairing with makes every one of those sums equal to . As is odd, is even, so that part of the product is , a perfect square. The whole product is a square times a square.
So every from to works and only does not, giving values.
Answer 36