#9. 「2020 AEC Final」B - Rectangle Flip 2

「2020 AEC Final」B - Rectangle Flip 2

题目描述

Prof. Pang enters a trap room in a dungeon. The room can be represented by an 𝑛𝑛 by 𝑚𝑚 chessboard.

We use (𝑖,𝑗)(1𝑖𝑛,1𝑗𝑚)(𝑖,𝑗)(1\leq 𝑖\leq 𝑛,1\leq 𝑗\leq 𝑚) to denote the cell at the 𝑖𝑖-th row and 𝑗𝑗-th column. Every second, the floor of one cell breaks apart (so that Prof. Pang can no longer stand on that cell.)

After nmn m seconds, there will be no cell to stand on and Prof. Pang will fall through to the next(deeper and more dangerous) level.

But Prof. Pang knows that calm is the key to overcome any challenge. So instead of being panic, he calculates the number of rectangles such that every cell in it is intact (i.e., not broken) after every second. (A rectangle represented by four integers 𝑎,𝑏,𝑐𝑎,𝑏,𝑐 and 𝑑(1𝑎𝑏𝑛,1𝑐𝑑𝑚)𝑑(1\leq 𝑎\leq 𝑏\leq 𝑛,1\leq 𝑐\leq 𝑑\leq 𝑚) includes all cells (𝑖,𝑗)(𝑖,𝑗) such that 𝑎𝑖𝑏,𝑐𝑗𝑑𝑎\leq 𝑖\leq 𝑏,𝑐\leq 𝑗\leq 𝑑. There are 𝑛(𝑛+1)2×m(m+1)2\frac {𝑛(𝑛+1)} 2 \times \frac {m(m+1)} 2rectangles in total.)

有个n*m的方阵,每次删掉一个格子,计算剩下的矩形数量。某个矩形存在当且仅当其覆盖的方格没有被删去任何一个

输入格式

The first line contains two integers 𝑛,𝑚(1𝑛,𝑚500)𝑛,𝑚(1\leq 𝑛,𝑚\leq 500) separated by a single space.

The (𝑖+1)(𝑖+1)-th line contains two integers 𝑎,𝑏𝑎,𝑏 separated by a single space representing that the cell (𝑎,𝑏)(𝑎,𝑏) breaks apart at the 𝑖𝑖-th second. It is guaranteed that each cell appears exactly once in the input.

输出格式

Output 𝑛m𝑛m lines. The 𝑖𝑖-th line should contain the number of rectangles such that every cell in it is intact after the first 𝑖𝑖 cells break apart.

样例

输入

2 2
1 1
2 1
1 2
2 2

输出

5
3
1
0

数据范围与提示

In the example, after the first second, there are 3 rectangles of area 1 and 2 rectangles of area 2 that satisfy the constraint. So the first line should contain a 5. After the second second, only cells in the second column remains intact. The answer should be 3. After the third second, only one cell remains intact. The answer should be 1. After the fourth second, all cells broke apart so the answer should be 0.