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

建议使用的浏览器:

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

7252:Painting Game

题目描述
There is a paper strip divided into $n$ blank grids. For each $i(1\leq i < n)$, grid $i$ and $i+1$ are considered adjacent.

Alice and Bob are going to play a game on the strip. They take turns to make move. In one move the player must paint one of the remaining blank grids black, while keeping the rule that no two black grids are adjacent.

The game ends when one of the players is unable to paint any grid, and the score of the game is defined as the total number of grids painted black. Alice wants to minimize the score, while Bob wants to maximize it.

Given $n$ and the side starting the game, find out the final score when both players play optimally.
输入解释
The first line contains an integer $T(1\leq T \leq 10^5)$ - the number of test cases.

The first line of each test case contains an integer $n(1 \leq n \leq 10^9)$ and a string $s (s \in \{\texttt{Alice},\texttt{Bob}\})$ - the number of grids and the starting player of this game.
输出解释
For each test case, output the final score when both players play optimally in a single line.
输入样例
4
3 Alice
3 Bob
19 Alice
23 Bob
输出样例
1
2
8
10

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

源链接: HDU-7252

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

共提交 0

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