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

建议使用的浏览器:

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

6992:Lawn of the Dead

题目描述
One day, a zombie came to the Lawn of the Dead, which can be seen as an $n\times m$ grid. Initially, he stood on the top-left cell, which is $(1,1)$.

Because the brain of the zombie was broken, he didn't have a good sense of direction. He could only move down from $(i,j)$ to $(i+1,j)$ or right from $(i,j)$ to $(i,j+1)$ in one step.

There were $k$ "lotato mines" on the grid. The $i$-th mine was at $(x_i,y_i)$. In case of being destroyed, he would never step into a cell containing a "lotato mine".

So how many cells could he possibly reach? (Including the starting cell)
输入解释
The first line contains a single integer $t$ ($1\leq t \leq 20$), denoting the number of test cases.

The first line of each test case contains three integers $n, m, k$ ($2\leq n,m,k \leq 10^5$) --- there was an $n\times m$ grid, and there were $k$ "lotato mines" on the grid.

Each of the following $k$ lines contains $2$ integers $x_i,y_i$ $(1\leq x_i\leq n, 1\leq y_i\leq m)$ --- there was a "lotato mine" at $(x_i,y_i)$. It's guaranteed that there was no "lotato mine" at $(1,1)$ and no mines were in the same cell.

It is guaranteed that $\sum n\le 7\cdot 10^5 , \sum m\le 7\cdot 10^5$.
输出解释
For each test case, output the number of cells he could possibly reach.
输入样例
1
4 4 4
1 3
3 4
3 2
4 3
输出样例
10
来自杭电HDUOJ的附加信息
Hint The cells that the zombie might reach are(1,1), (1,2), (2,1), (2,2), (2,3), (2,4), (3,1), (3,3), (4,1), (4,2).

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

源链接: HDU-6992

最后修改于 2021-10-23T19:10:56+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
8000/4000MS(Java/Others) 262144/262144K(Java/Others)