Problem:


Score : 500 points

Problem Statement

There are N Snuke Cats numbered 1, 2, \ldots, N, where N is even.

Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.

Recently, they learned the operation called xor (exclusive OR).

What is xor?

For n non-negative integers x_1, x_2, \ldots, x_n, their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows:

 When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. 

For example, 3~\textrm{xor}~5 = 6.

They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.

We know that the xor calculated by Snuke Cat i, that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i.
Using this information, restore the integer written on the scarf of each Snuke Cat.

Constraints

All values in input are integers.

2 \leq N \leq 200000

N is even.

0 \leq a_i \leq 10^9

There exists a combination of integers on the scarfs that is consistent with the given information.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 \ldots a_N

Output

Print a line containing N integers separated with space.

The i-th of the integers from the left should represent the integer written on the scarf of Snuke Cat i.

If there are multiple possible solutions, you may print any of them.

Sample Input 1

4
20 11 9 24

Sample Output 1

26 5 7 22

5~\textrm{xor}~7~\textrm{xor}~22 = 20

26~\textrm{xor}~7~\textrm{xor}~22 = 11

26~\textrm{xor}~5~\textrm{xor}~22 = 9

26~\textrm{xor}~5~\textrm{xor}~7 = 24

Thus, this output is consistent with the given information.



Sample input:
4
20 11 9 24


Sample output:
26 5 7 22

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
#-----

S_xor = 0
ans = []

for a in A_list:
    S_xor ^= a

for a in A_list:
    x = S_xor ^ a
    ans.append(x)

print(*ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    a = list(map(int, input().split()))
    L = [0]*(N+1)
    R = [0]*(N+1)
    for i in range(N):
        L[i+1] = L[i]^a[i]
        R[N-i-1] = R[N-i]^a[N-i-1]
    ans = [None]*N
    for i in range(N):
        ans[i] = L[i]^R[i+1]
    print(*ans)
    # print(L,R)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
all_xor = 0
for i in a:
    all_xor ^= i
for i in a:
    print(i ^ all_xor , end=' ')

Submission status: Accepted

Solution code:
# E - Red Scarf

N = int(input())
A = list(int(a) for a in input().split())

B = A[0]
for i in range(1, N):
    B ^= A[i]

C = []
for i in range(N):
    C.append(B^A[i])

print(' '.join(map(str, C)))

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))

t = 0
for e in a:
    t ^= e

print(*[e ^ t for e in a])

Submission status: Accepted

Solution code:
# bcd acd abd abc
# a^a = 0
# bcd ^ acd ^ abd ^ abc = a^b^c^d = total
# bcd ^ total = a^(b^b)^(c^c)^(d^d) = a

N = int(input())
xor_num = [int(x) for x in input().split()]
total = 0

for n in xor_num:
  total = total ^ n
for i in range(N):
  print(xor_num[i] ^ total, end=' ')

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))

from functools import reduce
xor = reduce(lambda x,y:x^y,A)

ans = [None] * N
for i in range(len(A)):
  ans[i] = xor ^ A[i]
  
print(*ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
xor_A = A[0]
for i in range(1, N, 1):
    xor_A = xor_A^A[i]
ans = [xor_A^a for a in A]
print(" ".join(map(str, ans)))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
xor = 0
for a in A:
    xor ^= a
ans = [0]*N
for i in range(31):
    bit = 2**i
    if xor&bit:
        for j in range(N):
            if not A[j]&bit: ans[j] += bit
    else:
        for j in range(N):
            if A[j]&bit: ans[j] += bit
print(*ans)

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**6)

n=int(input().rstrip())
a=[int(i) for i in input().split()]
cumxor1=[0]
cumxor2=[0]
ans=[]
for i in a:cumxor1.append(cumxor1[-1]^i)
for i in reversed(a):cumxor2.append(cumxor2[-1]^i)
cumxor2=list(reversed(cumxor2))
for i in range(n):
    ans.append(cumxor1[i]^cumxor2[i+1])
print(*ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    n = int(input())
    a = list(map(int, input().split()))
    xor = 0

    for ai in a:
        xor ^= ai

    tmp = xor
    ans = list()

    for ai in a:
        xor ^= ai
        ans.append(xor)
        xor = tmp

    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys,heapq
input = sys.stdin.buffer.readline

n = int(input())
a = list(map(int,input().split()))

p = 0
for e in a:
    p ^= e


res = [0]*n
for i in range(n):
    res[i] = a[i]^p

print(*res)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
S = 0
 
for i in a:
  S = S^i
  
ans = []
 
for i in a:
  ans.append(S^i)
  
print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
S = 0

for i in a:
  S = S^i
  
ans = []

for i in a:
  ans.append(S^i)
  
print(*ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
a=list(map(int,input().split()))
for i in range(n):
    ans^=a[i]
t=[]    
print(" ".join(str(ans^a[i]) for i in range(n)))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    xsum = 0
    for x in a:
        xsum = xsum ^ x
    print(" ".join(str(xsum ^ x) for x in a))
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split(" ")))
val = a[0]
for e in a[1:]:
    val ^= e
for e in a:
    print(val ^ e, end=' ')
print('')

Submission status: Accepted

Solution code:
import sys
# from math import sqrt, gcd, ceil, log
# from bisect import bisect
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	n = int(input()); arr = read()
	cum = arr[0]
	for i in arr[1:]:cum ^= i
	for i in range(n):arr[i] = arr[i]^cum
	print(*arr)

		

if __name__ == "__main__":
	solve()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = 0
for a_i in a:
  s ^= a_i
for a_i in a:
  print(s ^ a_i, end=' ')
print()

Submission status: Accepted

Solution code:
N=int(input())
A=[int(x) for x in input().split()]

t=0
for i in range(N):
  t^=A[i]

print(*[A[i]^t for i in range(N)])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

s = a[0]
for num in a[1:]:
  s ^= num

res = [0] * n
for i, num in enumerate(a):
  res[i] = s ^ num

print(*res)

Submission status: Accepted

Solution code:
from functools import reduce
def resolver(N, A):
    X = reduce(int.__xor__, A)
    ans = [str(X^a) for a in A]
    
    return ans

def test():
    pass

def main():

    #test()

    N = int(input())
    A = list(map(int, input().split()))
    ans = resolver(N, A)

    print(" ".join(ans))
    



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))

t = A[0]
for i in range(1,N):
    t = t ^ A[i]

l = []
for i in range(N):
    l.append(t^A[i])
print(" ".join(map(str,l)))

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))

xor = 0
for a in A:
    xor ^= a
result = []
for a in A:
    result.append(str(xor ^ a))
print(' '.join(result))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
allsum = 0
for i in a:
    allsum = allsum ^ i
 
for i in range(n):
    ans[i] = allsum ^ a[i]
print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
ai = [int(i) for i in input().split()]

ans = ai[0]

for i in range(n-1):
    ans = ans ^ ai[i+1]
    
ans_li = []

for i in range(n):
    ans_li.append(ans^ai[i])
    
print(*ans_li)

Submission status: Accepted

Solution code:
from collections import defaultdict
it = lambda: list(map(int, input().strip().split()))
INF = float('inf')

def solve():
    N = int(input())
    X = it()
    a = 0 
    for x in X:
        a = a ^ x
    
    ans = ''
    for x in X:
        ans += str(x ^ a) + ' '
    print(ans)

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
A = 0
for ai in a:
    A^=ai
ans = [A^ai for ai in a]
print(*ans)

Submission status: Accepted

Solution code:
t=int(input())
n=list(map(int,input().split()))
xor=0
for x in n:
  xor^=x
for x in n:
  print(x^xor,end=" ")

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
x = 0
for i in range(0, N):
    x ^= a[i]
ans = []
for i in range(0, N):
    ans.append(str(x ^ a[i]))

print(' '.join(ans))

Submission status: Accepted

Solution code:
n = int(input())
arr = [int(i) for i in input().split()]

left = [0]*n
xor = arr[0]
for i in range(1, n):
  left[i] = xor
  xor ^= arr[i]

right = [0]*n
xor = arr[n-1]
for i in range(n-2, -1, -1):
  right[i] = xor
  xor ^= arr[i]

for i in range(n):
  arr[i] = left[i] ^ right[i]

print(*arr)

Submission status: Accepted

Solution code:
N = int(input())
scarfs = list(map(int, input().split()))
xor_sum = scarfs[0]
for i in range(1, N):
    xor_sum = xor_sum ^ scarfs[i]

for scarf in scarfs:
    print(xor_sum ^ scarf, end=' ')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
xor = 0
for i in range(n):
    xor ^= a[i]
for i in range(n):
    print(xor ^ a[i],end = ' ')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
xor = 0
for i in a:
    xor = xor^i
for i in a:
    print(xor^i,end=" ")
print()

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

summ = 0
for i in A:
    summ ^= i

ans = []
for i in A:
    ans.append(summ^i)

print(" ".join(map(str, ans)))

Submission status: Accepted

Solution code:
n=int(input())

a=list(map(int, input().split()))
t1=0;
for i in range(n):
	t1^=a[i]


for i in range(n):
	a[i]=t1^a[i]
print(*a, sep=" ")

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
aa = a[0]
for i in range(1,n):
    aa = aa ^ a[i]
for i in range(n):
    print(aa ^ a[i],end=' ')

Submission status: Accepted

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = 0
    for a in A:
        x ^= a
    ret = [None]*N
    for i,a in enumerate(A):
        ret[i] = x ^ a
    print(*ret)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10**7)

ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n = ni()
a = na()

x = 0
for i in range(n):
    x ^= a[i]

ans = []
for i in range(n):
    ans.append(x ^ a[i])

print(*ans)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
s=0
for i in a:
  s^=i
b=[]
for j in range(n):
  b.append(s^a[j])
print(*b)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))

s = 0
for a_i in a:
    s ^= a_i

b = []
for a_i in a:
    b.append(str(s ^ a_i))

print(" ".join(b))

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
Xall=0
for a in A:
	Xall^=a
L=[]
for a in A:
	L.append(a^Xall)
print(*L)

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
a=A[0]
for i in range(n-1):
  a=a^A[i+1]
  
for i in range(n):
  print(a^A[i])

Submission status: Accepted

Solution code:
n=int(input())

t = list(map(int,input().split()))

sum_xor = t[0]

for i in range(1,n):
    sum_xor = sum_xor ^ t[i]

ans = []

for i in t:
    ans.append(sum_xor ^ i)

print(*ans)

Submission status: Accepted

Solution code:
n = int(input())
L = list(map(int,input().split()))
xor= 0
for i in range(n):
    xor ^=L[i]
li = []
for i in range(n):
    li.append(xor^L[i])
print(*li)

Submission status: Accepted

Solution code:
def solve(n, a):
    x = a[0]
    for i in range(1, n):
        x = x ^ a[i]
    ans = [x ^ a[i] for i in range(n)]
    return " ".join(map(str, ans))

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in A:
    ans^=i
ANS=[i^ans for i in A]
print(*ANS)

Submission status: Accepted

Solution code:
N = int(raw_input())

A = map(int, raw_input().split())

v = 0
for a in A:
  v ^= a
  
B = [v^a for a in A]

print " ".join(map(str, B))

Submission status: Accepted

Solution code:
n=int(input())
a=[int(j)for j in input().split()]
x=0
for i in a:
    x^=i
print(*[x^i for i in a])

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))

def binary(a):
    x = a
    out = ''
    while a>0:
        out = str(a % 2) + out
        a = int(a / 2)
    return out

binaryA = [0]*N
for i in range(N-1):
    binaryA[i] = binary(A[i])

S = 0

for i in A:
    S = S ^ i

ans = []
for i in A:
    ans.append(str(S^i))

print(' '.join(ans))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))

X = A[0]

for i in range(1, N):
    X = X ^ A[i]

for i in range(0, N):
    print(X ^ A[i], end=' ')

print('')

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int , input().split()))
b = []
s = 0
for ai in a:
    s ^= ai
ans = []
for ai in a:
    ans.append(s ^ ai)

print(' '.join(map(str, ans)))

Submission status: Accepted

Solution code:

N = int(input())

A = [int(x) for x in input().split(" ")]

x = 0
for a in A:
    x= x ^ a

for a in A:
    y = x ^ a
    print(y, end = " ")
print()

Submission status: Accepted

Solution code:
n,*a=map(int,open(0).read().split())
xor=0
for x in a:
	xor^=x
ans=[]
for y in a:
	ans+=y^xor,
print(*ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    total = 0
    for i_a in a:
        total ^= i_a

    ans = []
    for i_a in a:
        now_ans = 0
        for i_bin in range(49):
            if i_a & (1 << i_bin) == 0:
                if total & (1 << i_bin) != 0:
                    now_ans += (1 << i_bin)
            else:
                if total & (1 << i_bin) == 0:
                    now_ans += (1 << i_bin)

        ans.append(str(now_ans))

    print(' '.join(ans))
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Submission status: Accepted

Solution code:
N = int(input())

A = list(map(int, input().split()))

x = 0
for a in A:
  x ^= a

ans = []
for a in A:
  ans.append(x^a)
print(*ans)

Submission status: Accepted

Solution code:
def main():
    n = input()
    a = [int(v) for v in input().split()]
    xorsum = 0
    for v in a:
        xorsum ^= v
    for v in a:
        print(xorsum ^ v)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
As = list(map(int, input().split()))
s = 0
for A in As:
  s = s^A
rs = [s^A for A in As]
print(" ".join(map(str, rs)))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*A = map(int, read().split())
    
    X = 0
    for a in A:
        X ^= a

    ans = []
    for a in A:
        ans.append(a ^ X)

    print(*ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n  =readint()
a = readints()

b = 0
for i in range(n):
    b^=a[i]
ans = [b^a[i] for i in range(n)]

printline(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n  =readint()
a = readints()

if n%2==0:
    b = 0
    for i in range(n):
        b^=a[i]
    ans = [b^a[i] for i in range(n)]
else:
    b = a[0]
    ans = [0]+[b^a[i] for i in range(1,n)]

printline(ans)

Submission status: Accepted

Solution code:
n = int(input())
list_A = list(map(int, input().split()))
p = list_A[0]

for i in range(1, n):
    p ^= list_A[i]

list_ANS = []

for num in list_A:
    list_ANS.append(p^num)

print(*list_ANS)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(0,len(a)):
    ans=ans^a[i]
for i in range(0,len(a)):
    print(ans^a[i],end=" ")