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 )

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.


-----Input-----

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$.


-----Output-----

For each test case, print the name of the friend who could get the number $y$: "Alice" or "Bob".


-----Examples-----

Input
4
1 7 9
2
2 0 2
1 3
4 0 1
1 2 3 4
2 1000000000 3000000000
1000000000 1000000000
Output
Alice
Alice
Bob
Alice


-----Note-----

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$.

Source: codeforces | Difficulty: MEDIUM
Tags: Bit manipulation

Mathematics


Solutions:
import sys

def getline() -> str:
	return sys.stdin.readline().strip()

def solve():
	(n, x, y) = list(map(int, getline().split()))
	a = list(map(int, getline().split()))
	odds = 0
	for e in a:
		if e % 2 == 1:
			odds += 1
	if x % 2 == y % 2:
		if odds % 2 == 0:
			print('Alice')
			return
		else:
			print('Bob')
			return
	elif odds % 2 == 0:
		print('Bob')
		return
	else:
		print('Alice')
		return
t = int(getline())
for _ in range(t):
	solve()


import sys

def solve():
	inp = sys.stdin.readline
	(n, x, y) = map(int, inp().split())
	for i in map(int, inp().split()):
		x ^= i
	print(['Bob', 'Alice'][x & 1 == y & 1])

def main():
	for i in range(int(sys.stdin.readline())):
		solve()
main()


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, x, y) = map(int, input().split())
	li = list(map(int, input().split()))
	if (sum(li) + x) % 2 == y % 2:
		print('Alice')
	else:
		print('Bob')


from collections import defaultdict
import sys, math
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	s = sum(a)
	if (s + x + y) % 2 == 0:
		print('Alice')
	else:
		print('Bob')


import sys
input = sys.stdin.readline
MAX = sys.maxsize
sys.setrecursionlimit(10 ** 9)

def inp():
	return int(input())

def read_int_list():
	return list(map(int, input().split()))

def read_list():
	s = input()
	return list(s[:len(s) - 1])

def read_int_map():
	return map(int, input().split())

def solve(x, y, a):
	if sum(a) % 2 == (x - y) % 2:
		return 'Alice'
	return 'Bob'
for _ in range(inp()):
	(n, x, y) = read_int_list()
	a = read_int_list()
	print(solve(x, y, a))


from sys import stdin

def solve(n, x, y, s):
	nodd = len(list(filter(lambda x: x % 2 == 1, s)))
	return 'Alice' if (nodd + x + y) % 2 == 0 else 'Bob'
out = []
t = int(stdin.readline())
for _ in range(t):
	(n, x, y) = map(int, stdin.readline().strip().split(' '))
	s = list(map(int, stdin.readline().strip().split(' ')))
	out.append(solve(n, x, y, s))
print('\n'.join(map(str, out)))


def main():
	n = int(input())
	result = []
	for i in range(n):
		line = input().split()
		n = line[0]
		x = int(line[1])
		y = int(line[2])
		a = input().split()
		sum = 0
		for number in a:
			sum += int(number)
		if (sum + x + y) % 2 == 0:
			result.append('Alice')
		else:
			result.append('Bob')
	for i in result:
		print(i)
main()


out = []
for _ in range(int(input())):
	(n, x, y) = map(int, input().split())
	a = [int(i) for i in input().split()]
	for i in a:
		x ^= i
	if x % 2 == y % 2:
		out.append('Alice')
	else:
		out.append('Bob')
for i in out:
	print(i)


t = int(input())
res_array = []
for i in range(t):
	(len_list, alice_start, final_number) = input().split(' ')
	i_list = input().split(' ')
	alice_start = int(alice_start)
	alice_is_even = False
	final_number_is_even = int(final_number) % 2 == 0
	for Ai in i_list:
		alice_start += int(Ai)
		if alice_start % 2 == 0:
			alice_is_even = True
		else:
			alice_is_even = False
	if final_number_is_even == alice_is_even:
		res_array.append('Alice')
	else:
		res_array.append('Bob')
for j in res_array:
	print(j)


t = int(input())
answer = []
for i in range(0, t):
	(n, x, y) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	cnt = 0
	for i in range(0, n):
		if a[i] % 2 == 1:
			cnt += 1
	if x % 2 == y % 2:
		if cnt % 2 == 0:
			answer.append('Alice')
		else:
			answer.append('Bob')
	elif cnt % 2 == 0:
		answer.append('Bob')
	else:
		answer.append('Alice')
for x in answer:
	print(x)


import sys

def _input_iter():
	for line in sys.stdin:
		for part in line.strip().split(' '):
			stripped = part.strip()
			if stripped:
				yield stripped
stream = _input_iter()

def read_int():
	return int(next(stream))

def read_str():
	return next(stream)

def run():
	(n, x, y) = (read_int(), read_int(), read_int())
	a = []
	lsb_x = 'o' if x % 2 != 0 else 'e'
	lsb_y = 'o' if y % 2 != 0 else 'e'
	for i in range(n):
		current_number = read_int()
		if current_number % 2 == 0:
			if lsb_x == 'o':
				lsb_x = 'o'
			else:
				lsb_x = 'e'
		elif lsb_x == 'o':
			lsb_x = 'e'
		else:
			lsb_x = 'o'
	if lsb_x == lsb_y:
		print('Alice')
	else:
		print('Bob')
test_cases = read_int()
for _ in range(test_cases):
	run()


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_ls():
	return list(map(int, sys.stdin.readline().strip().split()))

def main():
	for _ in range(int(input())):
		(n, x, y) = map(int, input().split())
		ls = get_ls()
		for i in ls:
			x ^= i
		print('Alice' if x % 2 == y % 2 else 'Bob')
main()


t = int(input())
for _ in range(t):
	(n, x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	x = x + sum(a)
	if x % 2 == y % 2:
		print('Alice')
	else:
		print('Bob')


R = lambda : map(int, input().split())
(t,) = R()
while t:
	t -= 1
	(n, x, y) = R()
	print('ABloibc e'[x + y + sum(R()) & 1::2])


for _ in range(int(input())):
	(n, x, y) = map(int, input().split())
	if n == 1:
		arr = int(input())
		if (x + arr) % 2 == y % 2:
			print('Alice')
		else:
			print('Bob')
	else:
		arr = sum(list(map(int, input().split())))
		if (x + arr) % 2 == y % 2:
			print('Alice')
		else:
			print('Bob')


t = int(input())
for i in range(t):
	(n, x, y) = list(map(int, input().split()))
	m = list(map(int, input().split()))
	if (sum(m) + x + y) % 2 == 0:
		print('Alice')
	else:
		print('Bob')


def main():
	(n, x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	if (sum(a) + x + y) % 2 == 0:
		print('Alice')
	else:
		print('Bob')
for _ in range(int(input())):
	main()


def main():
	(n, x, y) = map(int, input().split())
	A = list(map(int, input().split()))
	print(['Alice', 'Bob'][(x + sum(A) + y) % 2])
for _ in range(int(input())):
	main()


t = int(input())

def solve():
	(n, x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	rem = sum(a) % 2
	if (x % 2 + rem) % 2 == y % 2:
		return 'Alice'
	return 'Bob'
for i in range(t):
	print(solve())


t = int(input())
for q in range(t):
	(a, b, c) = map(int, input().split())
	d = sum(list(map(int, input().split())))
	f = d + b
	f = f % 2
	g = c
	g = g % 2
	if g != f:
		print('Bob')
	else:
		print('Alice')


for i in range(int(input())):
	(n, x, y) = map(int, input().split())
	arr = list(map(int, input().split()))
	rem = sum(arr) % 2
	if (x % 2 + rem) % 2 == y % 2:
		print('Alice')
	else:
		print('Bob')


def solve():
	(n, x, y) = map(int, input().split())
	arr = list(map(int, input().split()))
	print('Alice' if (sum(arr) + x + y) % 2 == 0 else 'Bob')
tst = int(input())
while tst:
	solve()
	tst -= 1


for _ in range(int(input())):
	(n, a, g) = map(int, input().split())
	arr = list(map(int, input().split()))
	a += sum(arr)
	if a % 2 == g % 2:
		print('Alice')
	else:
		print('Bob')


def K():
	(n, x, y) = [int(w) for w in input().split()]
	a = [int(w) for w in input().split()]
	if (sum(a) + x + y) % 2 == 0:
		print('Alice')
	else:
		print('Bob')
s = int(input())
for i in range(s):
	K()


t = int(input())

def solve():
	(n, x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	if (sum(a) + x + y) % 2 == 0:
		print('Alice')
	else:
		print('Bob')
for i in range(t):
	solve()


t = int(input())
while t:
	(n, x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	s = sum(a)
	if (x + s) % 2 == y % 2:
		print('Alice')
	else:
		print('Bob')
	t -= 1


for _ in range(int(input())):
	(n, x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	s = sum(a)
	if s % 2 == 0:
		if x % 2 != 0 and y % 2 != 0:
			print('Alice')
		elif x % 2 == 0 and y % 2 == 0:
			print('Alice')
		else:
			print('Bob')
	elif x % 2 != 0 and y % 2 == 0:
		print('Alice')
	elif x % 2 == 0 and y % 2 != 0:
		print('Alice')
	else:
		print('Bob')


t = int(input())
for i in range(t):
	(n, alice, y) = [int(_) for _ in input().split()]
	a = [int(_) for _ in input().split()]
	if (sum(a) + alice + y) % 2 == 0:
		print('Alice')
	else:
		print('Bob')


for _ in range(int(input())):
	(n, x, y) = map(int, input().split(' '))
	l = list(map(int, input().split(' ')))
	total = x + y + sum(l)
	if total % 2 == 0:
		print('Alice')
	else:
		print('Bob')


T = int(input())
for k in range(T):
	(n, x, y) = [int(x) for x in input().split(' ')]
	a = map(int, input().split())
	xor = x
	for i in a:
		xor ^= i
	if xor % 2 == y % 2:
		print('Alice')
	else:
		print('Bob')


for _ in range(int(input())):
	(n, x, y) = map(int, input().split())
	x %= 2
	y %= 2
	k = sum((int(i) for i in input().split())) % 2
	if (k + x) % 2 == y:
		print('Alice')
	else:
		print('Bob')


def main():
	for _ in range(int(input())):
		(n, x, y) = map(int, input().split())
		(*arr,) = map(int, input().split())
		x += sum(arr)
		print('Alice' if x % 2 == y % 2 else 'Bob')
main()


t = int(input())
for i in range(t):
	(n, q, w) = map(int, input().split())
	a = list(map(int, input().split()))
	m = 0
	for j in a:
		if j % 2 == 1:
			m += 1
	if (q + m) % 2 == w % 2:
		print('Alice')
	else:
		print('Bob')


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	string = list(map(int, input().split()))
	if (sum(string) + b + c) % 2 == 0:
		print('Alice')
	else:
		print('Bob')


a = int(input())
for x in range(a):
	(b, c, d) = map(int, input().split())
	e = list(map(int, input().split()))
	s = sum(e)
	if (c + s) % 2 == d % 2:
		print('Alice')
	else:
		print('Bob')


k = int(input())
for i in range(k):
	(n, x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	if (sum(a) + x + y) % 2 == 0:
		print('Alice')
	else:
		print('Bob')


n = int(input())
for i in range(n):
	(n, x, y) = map(int, input().split())
	s = list(map(int, input().split()))
	a = sum(s) + x + y
	if not a % 2:
		print('Alice')
	else:
		print('Bob')


t = int(input())
while t:
	t -= 1
	(n, x, y) = map(int, input().split())
	a = map(int, input().split())
	print(('Alice', 'Bob')[x % 2 ^ sum(a) % 2 != y % 2])


for i in range(int(input())):
	(n, alice, resultado) = map(int, input().split())
	bob = alice + 3
	a = list(map(int, input().split()))
	print('Alice' if not (sum(a) + alice + resultado) % 2 else 'Bob')


nnn = int(input())
for _ in range(nnn):
	(n, d, k) = map(int, input().split())
	b = list(map(int, input().split()))
	for i in b:
		d += i
	if d % 2 == k % 2:
		print('Alice')
	else:
		print('Bob')


for _ in range(int(input())):
	(n, x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	for el in a:
		x ^= el
	if x & 1 == y & 1:
		print('Alice')
	else:
		print('Bob')


for _ in range(int(input())):
	(n, x, y) = map(int, input().split())
	temp = list(map(int, input().split()))
	ans = x
	for i in temp:
		ans = ans ^ i
	if ans % 2 == y % 2:
		print('Alice')
	else:
		print('Bob')


t = int(input())
out = []
for i in range(t):
	(n, x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	for j in a:
		x += j
	if x % 2 == y % 2:
		out.append('Alice')
	else:
		out.append('Bob')
for x in out:
	print(x)


for _ in range(int(input())):
	(n, x, y) = map(int, input().split())
	alice = x
	bob = x + 3
	numbers = list(map(int, input().split(' ')))
	countOdd = 0
	for num in numbers:
		if num % 2 != 0:
			countOdd += 1
	if (y - alice) % 2 == 0:
		if countOdd % 2 == 0:
			print('Alice')
		else:
			print('Bob')
	elif countOdd % 2 == 0:
		print('Bob')
	else:
		print('Alice')


def solve():
	(n, x, y) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	alc = (x + sum(a)) % 2
	y = y % 2
	if alc == y:
		return 'Alice'
	return 'Bob'
t = int(input())
for i in range(t):
	print(solve())


t = int(input())
for x in range(t):
	arr1 = [i for i in input().split()]
	total = sum([int(i) for i in input().split()]) + int(arr1[1])
	if total % 2 == int(arr1[2]) % 2:
		print('Alice')
	else:
		print('Bob')


import math
for i in range(int(input())):
	(n, x, y) = map(int, input().split())
	A = [int(k) for k in input().split()]
	alice = x
	blob = x + 3
	if sum(A) % 2 == abs(x - y) % 2:
		print('Alice')
	else:
		print('Bob')


def read_nums():
	return [int(x) for x in input().split()]

def solve():
	(n, alice, y) = read_nums()
	arr = read_nums()
	total = sum(arr) + y
	if total % 2 == alice % 2:
		return 'Alice'
	return 'Bob'

def main():
	(t,) = read_nums()
	for _ in range(t):
		print(solve())
main()


T = int(input())
for t in range(T):
	(n, x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	for ai in a:
		x += ai
	if x % 2 == y % 2:
		print('Alice')
	else:
		print('Bob')


for _ in range(int(input())):
	(n, x, y) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	z = 0
	for i in arr:
		x ^= i
	if x % 2 == y % 2:
		print('Alice')
	else:
		print('Bob')


import collections

def solve(n, x, y, arr):
	val = sum(arr) % 2
	if (x + val) % 2 == y % 2:
		print('Alice')
	else:
		print('Bob')
for _ in range(int(input())):
	(n, x, y) = map(int, input().split())
	arr = list(map(int, input().split()))
	solve(n, x, y, arr)


t = int(input())
while t != 0:
	t -= 1
	(n, x, y) = list(map(int, input().split()))
	new = list(map(int, input().split()))
	new1 = sum(new)
	if (new1 + x) % 2 == y % 2:
		print('Alice')
	else:
		print('Bob')


a = int(input())
for i in range(a):
	(b, c, d) = map(int, input().split())
	ei = list(map(int, input().split()))
	k = sum(ei)
	if (c + k) % 2 == 0 and d % 2 == 0:
		print('Alice')
	elif (c + k) % 2 != 0 and d % 2 != 0:
		print('Alice')
	else:
		print('Bob')


def multiple():
	a = map(int, input().split())
	return a

def array():
	a = input().split()
	return a

def intarray():
	a = list(map(int, input().split()))
	return a

def isplaindrome(s):
	if s == s[::-1]:
		return True
	return False

def solution():
	(n, x, y) = multiple()
	li = intarray()
	su = sum(li)
	if (su ^ x) % 2 == y % 2:
		print('Alice')
	else:
		print('Bob')
t = int(input())
for _ in range(t):
	solution()


for i in range(int(input())):
	(n, x, y) = map(int, input().split())
	numlist = [*map(lambda x: int(x), input().split())]
	to_operate = sum(numlist)
	(before_alice, before_bob) = (x % 2 == 0, (x + 3) % 2 == 0)
	if sum(numlist) % 2 == 0:
		(final_alice, final_bob) = (before_alice, before_bob)
	else:
		(final_alice, final_bob) = (not before_alice, not before_bob)
	if final_alice == (y % 2 == 0):
		print('Alice')
	else:
		print('Bob')