CF1634B.Fortune Telling
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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,…,n, in the increasing order of i. The possible operations are:
- replace their current number d with d+ai
- replace their current number d with d⊕ai (hereinafter ⊕ denotes the bitwise XOR operation)
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.
哈哈,来试试这个吧,SelectorUnlimited!
—— antontrygubO_o
你的朋友 Alice 和 Bob 正在练习占卜。
占卜过程如下:存在一个众所周知的、长度为 n 的非负整数数组 a,其下标从 1 到 n。被占卜者从某个非负整数 d 开始,对每个 i=1,2,…,n(按 i 升序进行),执行以下两种操作之一。可能的操作是:
- 将当前数 d 替换为 d+ai
- 将当前数 d 替换为 d⊕ai(此处 ⊕ 表示按位异或运算)
注意:对于不同的 i,以及对于不同的被占卜者,所选操作可以不同。
某次,Alice 决定从 d=x 开始,而 Bob 从 d=x+3 开始。他们各自独立完成占卜过程,并最终得到了某个特定的数。注意,两位朋友的操作选择是相互独立的,即对于相同的 i,他们可能选择了不同的操作。
你得知:Alice 或 Bob 中恰好一人最终得到了数 y,但你不知道究竟是谁。已知 Alice 和 Bob 的初始值以及 y,请判断 Alice 或 Bob 中谁有可能在执行完所有操作后得到 y。题目保证:在评测用例中,恰好只有一位朋友实际上能得到该数。
Hack
本题不允许 hack。
输入格式
On the first line of the input, you are given one number t (1≤t≤104) — the number of test cases. The following 2⋅t lines contain test cases.
The first line of each test case contains three numbers n, x, y (1≤n≤105, 0≤x≤109, 0≤y≤1015) — 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≤ai≤109).
It is guaranteed that the sum of n over all test cases does not exceed 105.
输入的第一行给出一个数字 t(1≤t≤104)——测试用例的数量。接下来的 2⋅t 行包含各测试用例。
每个测试用例的第一行包含三个数字 n、x、y(1≤n≤105,0≤x≤109,0≤y≤1015)——分别表示数组 a 的长度、Alice 的初始数字(因此 Bob 的初始数字为 x+3),以及两名朋友中某一人最终得到的数字。
每个测试用例的第二行包含 n 个数字——即数组 a(0≤ai≤109)。
保证所有测试用例的 n 之和不超过 105。
输出格式
For each test case, print the name of the friend who could get the number y: "Alice" or "Bob".
对于每个测试用例,输出能够得到数字 y 的朋友的名字:“Alice” 或 “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)⊕3=2.
In the third test case, Bob started with x+3=0+3=3 and could get 1 this way: (((3+1)+2)⊕3)⊕4=1.
在第一个测试用例中,Alice 可以通过以下运算得到 9:7+2=9。
在第二个测试用例中,Alice 可以通过以下运算得到 2:(0+1)⊕3=2。
在第三个测试用例中,Bob 初始值为 x+3=0+3=3,并可通过如下方式得到 1:(((3+1)+2)⊕3)⊕4=1。
输入解题思路,AI测评打分。不知道怎么写?