当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6699:Block Breaker

题目描述
Given a rectangle frame of size $n\times m$. Initially, the frame is strewn with $n\times m$ square blocks of size $1\times 1$. Due to the friction with the frame and each other, the blocks are stable and will not drop.

However, the blocks can be knocked down. When a block is knocked down, other remaining blocks may also drop since the friction provided by other remaining blocks may not sustain them anymore. Formally, a block will drop if it is knocked or not stable, which means that at least one of the left block and the right block has been dropped and at least one of the front block and the back block has been dropped. Especially, the frame can be regarded as a huge stable block, which means that if one block's left is the frame, only when its right block has been dropped and at least one of the front block and the back block has been dropped can it drop. The rest situations are similar.

Now you, the block breaker, want to knock down the blocks. Formally, you will do it $q$ times. In each time, you may choose a position $(x_i, y_i)$. If there remains a block at the chosen position, you will knock it down; otherwise, nothing will happen. Moreover, after knocking down the block, you will wait until no unstable blocks are going to drop and then do the next operation.

For example, please look at the following illustration, the frame is of size $2\times 2$ and the block $(1,1)$ and $(1,2)$ have been dropped. If we are going to knock the block $(2,2)$, not only itself but also the block $(2,1)$ will drop in this knocking operation.



You want to know how many blocks will drop in total in each knocking operation. Specifically, if nothing happens in one operation, the answer should be regarded as $0$.
输入解释
The first line contains one positive integer $T~(1\le T \le 10)$, denoting the number of test cases.

For each test case:

The first line contains three positive integers $n,m$ and $q~(1\le n,m\le 2\,000, 1\le q\le 100\,000)$, denoting the sizes in two dimensions of the frame and the number of knocking operations.

Each of the following $q$ lines contains two positive integers $x_i$ and $y_i~(1\le x_i\le n, 1\le y_i \le m)$, describing a knocking operation.
输出解释
For each test case, output $q$ lines, each of which contains a non-negative integer, denoting the number of dropped blocks in the corresponding knocking operation.
输入样例
2
2 2 3
1 1
1 2
2 2
4 4 6
1 1
1 2
2 1
2 2
4 4
3 3
输出样例
1
1
2
1
1
2
0
1
11
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6699

最后修改于 2020-10-25T23:33:36+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/2000MS(Java/Others) 524288/524288K(Java/Others)