#P5917. [IOI 1995] 铺放矩形块

[IOI 1995] 铺放矩形块

Problem Description

Given 44 rectangles, find a smallest enclosing rectangle that can contain all 44 rectangles without overlapping. “Smallest” means the enclosing rectangle has the minimum area.

All sides of the 44 rectangles are parallel to the sides of the enclosing rectangle.

There may be multiple different enclosing rectangles with the same minimum area. You should output the side lengths of all such enclosing rectangles.

Input Format

The input has 44 lines. Each line contains two positive integers representing the two side lengths of one given rectangle. The side length of each rectangle is at least 11 and at most 5050.

Output Format

The total number of output lines is the number of solutions plus 11. The first line is an integer representing the minimum area of the enclosing rectangle (Subtask AA). Each following line represents one solution, given by two numbers PP and QQ, with PQP \leq Q (Subtask BB). These lines must be sorted in increasing order of PP (smaller PP first). All lines must be distinct.

1 2
2 3
3 4
4 5
40
4 10
5 8

Hint

Translated by ChatGPT 5