#P1212. [USACO1.4] 铺放矩形块 Packing Rectangles

[USACO1.4] 铺放矩形块 Packing Rectangles

Description

Given 44 rectangles, find a smallest enclosing rectangle that can contain all 44 rectangles without overlap. By “smallest” we mean the area is minimal.

For any of the 44 rectangles, its sides must be parallel to the sides of the enclosing rectangle. The figure above shows 66 ways to pack the 44 rectangles.

These 66 layouts are the only possible basic layouts. Any other layout can be obtained from a basic one by rotation or mirror reflection.

There may be multiple enclosing rectangles that satisfy the conditions and have the same area; you should output the side lengths of all such enclosing rectangles.

Input Format

There are 44 lines, each containing two positive integers, representing the side lengths of each rectangle.

Output Format

The total number of lines equals the number of solutions plus one.

The first line is an integer, representing the minimal area of the enclosing rectangle.
Each of the following lines describes one solution, represented by p,q (pq)p,q\space (p \leqslant q). These lines must be sorted in ascending order by pp, and all lines must be distinct.

1 2
2 3
3 4
4 5

40
4 10
5 8

Hint

Constraints
For 100%100\% of the testdata, all input numbers are in [1, 50].

Problem translation from NOCOW.

USACO Training Section 1.4.

Translated by ChatGPT 5