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

建议使用的浏览器:

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

6123:Destroy the cube

题目描述
There is a chessboard with $n$ rows and $n$ columns, every position is black or white. It is defined that $c(x,y)$ means the color of the position in the $x$th row and the $y$th column, and it is guaranteed that $c(x,y)=c(y,x)=c(x,n-y+1)=c(n-x+1,y)$ for any $1\leq x,y\leq n$, which shows it is quite symmetry. Also because of this, only the colors of the positions $(x,y)$ which satisfies $x\leq y\leq\lfloor\frac{n+1}{2}\rfloor$ are given, and the number of the given black position is $t$ in total. Now HazelFan has a big cube with $n$ layers and $n$ rows and $n$ lines, and its six sides are all same as the chessboard. For the three pairs of opposite sides, for each black position on one side, he will dig through the cube from the position straight to a black position on the other side. Please tell him after he destroys the cube, how many little cubes are left.
输入解释
The first line contains a positive integer $T(1\leq T\leq5)$, denoting the number of test cases.
For each test case:
The first line contains two positive integers $n,t(1\leq n\leq6\times10^4,1\leq t\leq1.2\times10^5)$.
The next $t$ lines, each line contains two positive integers $x,y(1\leq x\leq y\leq\lfloor\frac{n+1}{2}\rfloor)$, denoting a given black position.
输出解释
For each test case:
A single line contains a nonnegative integer, denoting the answer.
输入样例
2
3 1
2 2
5 2
2 3
3 3
输出样例
20
76
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6123

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

共提交 0

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