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

建议使用的浏览器:

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

7212:Black Magic

题目描述
HoshiYo is learning Black Magic with $n$ blocks. The left and right sides of each block are painted black or white. HoshiYo arranges the blocks in a row in a certain order without rotating them and then releases the Black Magic. Here's what happens next:
  • For any two adjacent blocks, if the right side of the left block and the left side of the right block are both painted black, then the two sides will be pasted together making the two blocks into one.
HoshiYo wants to know the minimum and maximum blocks he can get after releasing the Black Magic.
输入解释
The first line contains an integer $T$ ($1 \le T \le 4\times 10^3$), indicating the number of test cases.

Each test case contains four integers $E,L,R,B$ ($0 \le E,L,R,B \le 10^5, E+L+R+B\ge 1$), indicating the number of blocks.
  • $E$: the number of blocks whose both sides are painted white.
  • $L$: the number of blocks whose left side is painted black and right side is painted white.
  • $R$: the number of blocks whose right side is painted black and left side is painted white.
  • $B$: the number of blocks whose both sides are painted black.
It guaranteed that the sum of $E+L+R+B$ over all test cases won't exceed $10^6$.
输出解释
For each test case, output two integers in a single line, indicating the minimum and maximum blocks HoshiYo can get.
输入样例
3
1 1 1 1
1 2 3 4
3 4 5 6
输出样例
2 4
4 8
8 16
来自杭电HDUOJ的附加信息
Hint Let's denote a block by $(x,y)$, where $x$ indicates the color on the left side, and $y$ indicates the color on the right side. We use $0$ to represent white and $1$ to represent black.For the first test case in the sample, here is a possible solution to get the minimum number of blocks:$$(0,0) \quad (0,1) \quad (1,1) \quad (1,0)$$As shown above, the last three blocks will be pasted into one.And here is a possible solution to get the maximum number of blocks:$$(0,0) \quad (1,0) \quad (1,1) \quad (0,1)$$As shown above, any two blocks will not be pasted together.

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

源链接: HDU-7212

最后修改于 2022-09-15T06:17:26+00:00 由爬虫自动更新

共提交 0

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