logo AlgoBeat OnlineJudge
登录 注册

#217724. [ICPC 2026 Wuhan I] Rectangle Cutting

内存限制:512 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Yachiyo has a rectangle in the first quadrant of the Cartesian coordinate plane. The lower-left corner of the rectangle is at the origin , and the upper-right corner is at . In other words, the two sides of the rectangle are aligned with the -axis and the -axis, with lengths and along the - and -directions, respectively.

Yachiyo decides to make cuts on this rectangle. Specifically, there are two kinds of cuts:

  • Horizontal cut: given a positive integer , cut along the line .
  • Vertical cut: given a positive integer , cut along the line .

Each cut goes through the entire region, further dividing the existing rectangles into more smaller rectangles.

Yachiyo wants to know, after each cut is completed, what the maximum area among all the currently divided small rectangles is.

输入格式

The first line contains three integers (, ), representing the horizontal length, vertical length, and the number of cuts of the initial rectangle, respectively.

The next lines each contain two integers , describing one cut operation:

  • If , it means a vertical cut is performed, and the given integer () indicates cutting along the line .
  • If , it means a horizontal cut is performed, and the given integer () indicates cutting along the line .

It is guaranteed that Yachiyo will never cut at the same position twice (that is, all cutting lines are distinct).

输出格式

Output lines. The -th line should contain one integer, representing the maximum area among all small rectangles after the -th cut.

样例

样例输入 1

5 3 3
1 1
1 4
2 2

样例输出 1

12
9
6

数据范围与提示

:::align{center}

Pic. 1: Sample explanation :::