Bohemian Rhaksody

View as PDF

Submit solution

Points: 45 (partial)
Time limit: 4.5s
Memory limit: 1G

Author:
Problem type

MolaMola is a world-famous rock band composed of three members: Guitarist Sangsoo cki86201 Park famous for his amazing performance with Link-cut tree, drummer Sunggwan dotorya Park who plays 5 problems in 10 minutes without a single WA, and the vocalist Bumsoo zlzmsrhak Park who is responsible for the impressive outlook of the band. The movie about their story, Bohemian Rhaksody, became a blockbuster in Korea, and they are preparing for their perfect comeback concert.

Bumsoo, famous for his unique sense of fashion, thinks that perfect concerts need not only the best music but also great visual effects. Needless to say, the illumination setting is a very important matter for him.

The stage given to them is an H \times W size rectangle with four corners in (0, 0), (0, W), (H, 0), (H, W), and there are N bulbs already installed in the stage. Note that the bulbs may lie on the boundary, but are not strictly outside. To prevent interference, each bulb has a distinct x-coordinate, and each bulb also has a distinct y-coordinate. Every bulb is designed to light either the east/west/south/north part of the stage. More formally, the bulb at the coordinate (X, Y) can be operated in one of the following modes:

  • Light the area of the stage where x \le X.
  • Light the area of the stage where x \ge X.
  • Light the area of the stage where y \le Y.
  • Light the area of the stage where y \ge Y.

Bumsoo wants their band to play in the brightest area, so the stage will be exactly the area that is lit by all N bulbs. Now, Bumsoo wants to find a way to operate the bulbs, in order to maximize the area of their stage. Help him!

Input Specification

The first line contains three integers H, W, N. (1 \le N \le 100\,000, 1 \le H, W \le 10^8)

In the next N lines, two integers X, Y are given, indicating that the bulb is installed in coordinate (X, Y). (0 \le X \le H, 0 \le Y \le W)

It is guaranteed that no pair of different bulbs share an x-coordinate, and no pair of different bulbs share a y-coordinate.

Output Specification

Print the maximum possible area that can be lit by all N bulbs.

Sample Input 1

4 4 5
0 4
1 3
2 2
3 1
4 0

Sample Output 1

6

Sample Input 2

100000000 100000000 1
0 0

Sample Output 2

10000000000000000

Sample Input 3

100000000 100000000 12
100000000 59411855
0 4914151
57454627 45388814
93661922 93279520
81531691 0
5221549 64790529
75886863 85609174
74950464 100000000
18493301 57818271
66752434 90450964
44757377 54518291
99631520 21997156

Sample Output 3

4522156529817280

Comments

There are no comments at the moment.