A14224 | Chips on a Board
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Alice and Bob have a rectangular board consisting of $n$ rows and $m$ columns. Each row contains exactly one chip.
Alice and Bob play the following game. They choose two integers $l$ and $r$ such that $1 \le l \le r \le m$ and cut the board in such a way that only the part of it between column $l$ and column $r$ (inclusive) remains. So, all columns to the left of column $l$ and all columns to the right of column $r$ no longer belong to the board.
After cutting the board, they move chips on the remaining part of the board (the part from column $l$ to column $r$ ). They make alternating moves, and the player which cannot make a move loses the game. The first move is made by Alice, the second — by Bob, the third — by Alice, and so on. During their move, the player must choose one of the chips from the board and move it any positive number of cells to the left (so, if the chip was in column $i$ , it can move to any column $j < i$ , and the chips in the leftmost column cannot be chosen).
Alice and Bob have $q$ pairs of numbers $L_i$ and $R_i$ . For each such pair, they want to determine who will be the winner of the game if $l = L_i$ and $r = R_i$ . Note that these games should be considered independently (they don't affect the state of the board for the next games), and both Alice and Bob play optimally.
Alice and Bob play the following game. They choose two integers $l$ and $r$ such that $1 \le l \le r \le m$ and cut the board in such a way that only the part of it between column $l$ and column $r$ (inclusive) remains. So, all columns to the left of column $l$ and all columns to the right of column $r$ no longer belong to the board.
After cutting the board, they move chips on the remaining part of the board (the part from column $l$ to column $r$ ). They make alternating moves, and the player which cannot make a move loses the game. The first move is made by Alice, the second — by Bob, the third — by Alice, and so on. During their move, the player must choose one of the chips from the board and move it any positive number of cells to the left (so, if the chip was in column $i$ , it can move to any column $j < i$ , and the chips in the leftmost column cannot be chosen).
Alice and Bob have $q$ pairs of numbers $L_i$ and $R_i$ . For each such pair, they want to determine who will be the winner of the game if $l = L_i$ and $r = R_i$ . Note that these games should be considered independently (they don't affect the state of the board for the next games), and both Alice and Bob play optimally.
输入格式
The first line contains two integers $n$ and $m$ ( $1 \le n, m \le 2 \cdot 10^5$ ) — the number of rows and columns on the board, respectively.
The second line contains $n$ integers $c_1, c_2, \dots, c_n$ ( $1 \le c_i \le m$ ), where $c_i$ is the index of the column where the chip in the $i$ -th row is located (so, the chip in the $i$ -th row is in the $c_i$ -th column).
The third line contains one integer $q$ ( $1 \le q \le 2 \cdot 10^5$ ).
Then $q$ lines follow, the $i$ -th of them contains two integers $L_i$ and $R_i$ ( $1 \le L_i \le R_i \le m$ ).
The second line contains $n$ integers $c_1, c_2, \dots, c_n$ ( $1 \le c_i \le m$ ), where $c_i$ is the index of the column where the chip in the $i$ -th row is located (so, the chip in the $i$ -th row is in the $c_i$ -th column).
The third line contains one integer $q$ ( $1 \le q \le 2 \cdot 10^5$ ).
Then $q$ lines follow, the $i$ -th of them contains two integers $L_i$ and $R_i$ ( $1 \le L_i \le R_i \le m$ ).
输出格式
Print a string of $q$ characters. The $i$ -th character should be A if Alice wins the game with $l = L_i$ and $r = R_i$ , or B if Bob wins it.
输入输出样例
输入 #1
8 10 1 3 3 7 4 2 6 9 7 2 3 1 3 1 4 1 10 5 10 8 10 9 10
输出 #1
BAAAAAB
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted