1634B.md (2855B)
1 Source: https://codeforces.com/problemset/problem/1634/B 2 3 B. Fortune Telling 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Haha, try to solve this, SelectorUnlimited! 22 23 — antontrygubO_o 24 25 Your friends Alice and Bob practice fortune telling. 26 27 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: 28 29 * replace their current number $d$ with $d + a_i$ 30 * replace their current number $d$ with $d \oplus a_i$ (hereinafter $\oplus$ denotes the [bitwise XOR operation](https://en.wikipedia.org/wiki/Exclusive_or)) 31 32 Notice that the chosen operation may be different for different $i$ and for different tellees. 33 34 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$. 35 36 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. 37 38 Hacks 39 40 You cannot make hacks in this problem. 41 42 Input 43 44 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. 45 46 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. 47 48 The second line of each test case contains $n$ numbers — the array $a$ ($0 \le a_i \le 10^9$). 49 50 It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$. 51 52 Output 53 54 For each test case, print the name of the friend who could get the number $y$: "Alice" or "Bob". 55 56 Example 57 58 Input 59 60 ``` 61 4 62 63 1 7 9 64 65 2 66 67 2 0 2 68 69 1 3 70 71 4 0 1 72 73 1 2 3 4 74 75 2 1000000000 3000000000 76 77 1000000000 1000000000 78 ``` 79 80 Output 81 82 ``` 83 Alice 84 Alice 85 Bob 86 Alice 87 ``` 88 89 Note 90 91 In the first test case, Alice could get $9$ using the following operations: $7 + 2 = 9$. 92 93 In the second test case, Alice could get $2$ using this operations: $(0 + 1) \oplus 3 = 2$. 94 95 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$.