|
||||||||||
Painting GameTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 456 Accepted Submission(s): 212 Problem Description 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. Input 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. Output For each test case, output the final score when both players play optimally in a single line. Sample Input
Sample Output
Source | ||||||||||
|