A14777 | Fortune Telling
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Haha, try to solve this, SelectorUnlimited!
— antontrygubO_o
Your friends Alice and Bob practice fortune telling.
Fortune telling is performed as follows. There is a well-known array $a$ of $n$ non-negative integers indexed from $1$ to $n$ . The tellee starts with some non-negative number $d$ and performs one of the two operations for each $i = 1, 2, \ldots, n$ , in the increasing order of $i$ . The possible operations are:
- replace their current number $d$ with $d + a_i$
- replace their current number $d$ with $d \oplus a_i$ (hereinafter $\oplus$ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Exclusive_or))
Notice that the chosen operation may be different for different $i$ and for different tellees.
One time, Alice decided to start with $d = x$ and Bob started with $d = x + 3$ . Each of them performed fortune telling and got a particular number in the end. Notice that the friends chose operations independently of each other, that is, they could apply different operations for the same $i$ .
You learnt that either Alice or Bob ended up with number $y$ in the end, but you don't know whose of the two it was. Given the numbers Alice and Bob started with and $y$ , find out who (Alice or Bob) could get the number $y$ after performing the operations. It is guaranteed that on the jury tests, exactly one of your friends could have actually gotten that number.
Hacks
You cannot make hacks in this problem.
— antontrygubO_o
Your friends Alice and Bob practice fortune telling.
Fortune telling is performed as follows. There is a well-known array $a$ of $n$ non-negative integers indexed from $1$ to $n$ . The tellee starts with some non-negative number $d$ and performs one of the two operations for each $i = 1, 2, \ldots, n$ , in the increasing order of $i$ . The possible operations are:
- replace their current number $d$ with $d + a_i$
- replace their current number $d$ with $d \oplus a_i$ (hereinafter $\oplus$ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Exclusive_or))
Notice that the chosen operation may be different for different $i$ and for different tellees.
One time, Alice decided to start with $d = x$ and Bob started with $d = x + 3$ . Each of them performed fortune telling and got a particular number in the end. Notice that the friends chose operations independently of each other, that is, they could apply different operations for the same $i$ .
You learnt that either Alice or Bob ended up with number $y$ in the end, but you don't know whose of the two it was. Given the numbers Alice and Bob started with and $y$ , find out who (Alice or Bob) could get the number $y$ after performing the operations. It is guaranteed that on the jury tests, exactly one of your friends could have actually gotten that number.
Hacks
You cannot make hacks in this problem.
输入格式
On the first line of the input, you are given one number $t$ ( $1 \le t \le 10^4$ ) — the number of test cases. The following $2 \cdot t$ lines contain test cases.
The first line of each test case contains three numbers $n$ , $x$ , $y$ ( $1 \le n \le 10^5$ , $0 \le x \le 10^9$ , $0 \le y \le 10^{15}$ ) — the length of array $a$ , Alice's initial number (Bob's initial number is therefore $x+3$ ), and the number that one of the two friends got in the end.
The second line of each test case contains $n$ numbers — the array $a$ ( $0 \le a_i \le 10^9$ ).
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$ .
The first line of each test case contains three numbers $n$ , $x$ , $y$ ( $1 \le n \le 10^5$ , $0 \le x \le 10^9$ , $0 \le y \le 10^{15}$ ) — the length of array $a$ , Alice's initial number (Bob's initial number is therefore $x+3$ ), and the number that one of the two friends got in the end.
The second line of each test case contains $n$ numbers — the array $a$ ( $0 \le a_i \le 10^9$ ).
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$ .
输出格式
For each test case, print the name of the friend who could get the number $y$ : "Alice" or "Bob".
输入输出样例
输入 #1
4 1 7 9 2 2 0 2 1 3 4 0 1 1 2 3 4 2 1000000000 3000000000 1000000000 1000000000
输出 #1
Alice Alice Bob Alice
In the first test case, Alice could get $9$ using the following operations: $7 + 2 = 9$ .
In the second test case, Alice could get $2$ using this operations: $(0 + 1) \oplus 3 = 2$ .
In the third test case, Bob started with $x+3 = 0+3=3$ and could get $1$ this way: $(((3 + 1) + 2) \oplus 3) \oplus 4 = 1$ .
In the second test case, Alice could get $2$ using this operations: $(0 + 1) \oplus 3 = 2$ .
In the third test case, Bob started with $x+3 = 0+3=3$ and could get $1$ this way: $(((3 + 1) + 2) \oplus 3) \oplus 4 = 1$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted