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:
import numpy as np
n = int(input())
a = np.array([int(a) for a in input().split()])


# とりあえず，答え（自分）と自分以外のxorのxorは全て同じになることはわかる．
# xor 可換そうだから，２つお互いを比べればそのindexのやつらのxorと同値っぽい
# 2つのxorだと1や0の数は絞られてきそう？
# 全体のxorはすべてを一度ずつ使ったxorになる
totalxor = a[0]
for i in range(1, len(a)):
  totalxor = totalxor^a[i]

print(' '.join([str(i^totalxor) for i in a]))

Submission status: Accepted

Solution code:
n = int(input())
alist = list(map(int,input().split()))
asum = 0
for i in range(n):
    asum ^= alist[i]
anslist = []
for i in range(n):
    asum ^= alist[i]
    anslist.append(asum)
    asum ^= alist[i]
for ans in anslist:
    print(ans ,end = ' ')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))
s=np.bitwise_xor.reduce(a)
#print(s)
b=np.bitwise_xor(a,s)
print(" ".join((str(x) for x in b)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
n=int(input())
A=list(map(int,input().split()))
C=A
A=np.array(A)
length=len(format(max(A),"b"))

B=""
for i in range(length):
    cnt=np.count_nonzero(A&1)
    if cnt%2==0:B +="0"
    else:B +="1"
    A >>=1

B=int(B[::-1],2)
D=[]
for i in C:
    D.append(B^i)
print(*D)

Submission status: Accepted

Solution code:
n = int(input())
a=list(map(int,input().split()))
forward = []
back = []
result = ''
t = 0
for i in range(n):
    t ^= a[i]
    forward.append(t)
t = 0
for i in range(n-1, -1, -1):
    t ^= a[i]
    back.append(t)

for i in range(n):
    if i == 0:
        t = back[n-2]
    elif i == n-1:
        t = forward[n-2]
    else:
        t = forward[i-1] ^ back[n-2-i]
    result += str(t) + ' '

print(result)

Submission status: Accepted

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

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

for i in range(n):
    print(p^A[i])

Submission status: Accepted

Solution code:
from functools import reduce
n = int(input())
al = list(map(int, input().split()))
ansl = [0]*n
test_list = al
  
# printing original list 

  
# List XOR 
# Using reduce() + lambda + "^" operator 
res = reduce(lambda x, y: x ^ y, test_list) 
  
# printing result  
sum = res
for i in range(n):
    ansl[i] = res^al[i]

"""
for i,youso in enumerate(al):
    for j in range(n):
        if i == j:
            continue
        else:
            ansl[j] ^= youso 

"""
print(' '.join(map(str, ansl)))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    k = max(a).bit_length()
    c = [0] * n
    for i in range(k):
        b = [ai // 2**i % 2 for ai in a]
        if sum(b) % 2:
            b = [1 - bi for bi in b]
        for j in range(n):
            c[j] += b[j] * 2**i
    print(*c)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
AList = list(map(int, input().split()))
RList = []
tmp = 0
tmppoint = 0
for i in range(1, len(AList)):
    tmp = tmp ^ AList[i]

RList.append(tmp)
for p in range(1, len(AList)):
    tmp = tmp ^ AList[tmppoint]
    tmp = tmp ^ AList[p]
    tmppoint = p
    
    RList.append(tmp)

for i in range(len(RList)):
    print(RList[i], end=' ')

Submission status: Accepted

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

S = A[0]
for i in range(1, N):
    S = S ^ A[i]
# print('S', S)

# for a in A[:-1]:
#     print(S ^ a, sep='', end=' ')

S = [str(S ^ a) for a in A]
print(' '.join(S))

Submission status: Accepted

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

a_xor = a[0]
for i in range(1, N):
    a_xor = a_xor ^ a[i]
    
ans = []
for i in range(N):
    ans.append(a_xor ^ a[i])
print(*ans)

Submission status: Accepted

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

res = bin(0)
for i in range(n):
    res = bin(int(res,2)^al[i])

resu=[]
for j in range(n):
    ress = bin(int(res,2)^al[j])
    resu.append(int(ress,2))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = [int(a) for a in input().split()]
ALL = 0b0
for i in range(N):
    ALL = ALL ^ A[i]
for i in range(N):
    print(ALL ^ A[i])

Submission status: Accepted

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

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
key=0
for i in A:
    key=int(bin(key^i),2)
for i in A:
    print(int(bin(key^i),2), end=" ")

Submission status: Accepted

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

def xor(num_list):
  result = 0
  for num in num_list:
    result ^= num
  return result

xor_a = xor(A)

print(" ".join([str(xor_a ^ a) for a in A]))

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
dic={tl:0 for tl in range(n)}

l=1
while max(A)>0:
  Q=[a%2 for a in A]
  A=[a//2 for a in A]
  s=sum(Q)
  if s%2==1:
    for i in range(n):
      if Q[i]==0:
       dic[i]+=l
  else:
    for i in range(n):
      if Q[i]==1:
       dic[i]+=l
  l*=2

for i in range(n):
  print(dic[i])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

N = int(input())
A = list(map(int, sys.stdin.readline().rsplit()))

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

for a in A:
    print(t ^ a)

Submission status: Accepted

Solution code:
import numpy as np
from numba import jit, njit
import copy

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

# n = 4
# a = [20, 11, 9, 24]

# O(n)
base = 0
for _a in a:
    base = base ^ _a

# print('base', base)

# O(n)
xors = []
for i in range(n):
    xors.append(base ^ a[i])

xors = [str(x) for x in xors]

# print('xors', xors)
print(' '.join(xors))

Submission status: Accepted

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

Submission status: Accepted

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

X = 0
for i in range(N):
    X ^= a[i]
#print(X)

answers = []
for i in range(N):
    #print(i+1,a[i])
    #print()
    answers.append(X^a[i])
    #X=20^a_1
    #X=11^a_2
    #X=9^a_3
    #X=24^a_4

    #0=20^11^9^24^X
print(*answers)

Submission status: Accepted

Solution code:
n=int(input())

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

tmp=[]

for i in range(n):
    if i%2==1:
        continue
    x=a[i]^a[i+1]
    tmp.append(x)

S=0
for j in range(len(tmp)):
    S = S^tmp[j]

ans=[]

for k in range(n):
    p = a[k]^S
    ans.append(p)

print(*ans)

Submission status: Accepted

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

ans = [0] * N
for i in range(N):
    ans[i] = al ^ A[i]
print(" ".join(map(str, ans)))

Submission status: Accepted

Solution code:
from sys import stdin, stdout
from collections import Counter
for _ in range(1):#int(stdin.readline())
    n=int(stdin.readline())
    a=list(map(int, stdin.readline().split()))
    xor=0
    for v in a:xor^=v
    ans=[]
    for v in a:
        ans+=[v^xor]
    print(*ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

N = int(sys.stdin.readline())
a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param

left = [0]*(N+1)
for i in range(N):
    left[i+1] = left[i]^a[i]

right = [0]*(N+1)
for i in range(N)[::-1]:
    right[i] = right[i+1]^a[i]

#print(left,right)

ret = []
for i in range(N):
    #print(i,left[max(0,i)],right[i+1])
    ret.append(left[max(0,i)]^right[i+1])

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

Submission status: Accepted

Solution code:
from functools import reduce

N = int(input().strip())
A = [int(x) for x in input().strip().split(" ")]
xor = reduce(lambda x, y: x ^ y, A)

print(" ".join([
    str(xor ^ a)
    for a in A
]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
#, setrecursionlimit, stdout
#setrecursionlimit(1000000)
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return list(mi())
def si(): return stdin.readline().rstrip()
def lsi(): return list(si())
#mod=1000000007
res=['Yes', 'No']
############# CODE STARTS HERE #############


test_case=1
while test_case:
    test_case-=1

    n=ii()
    a=li()
    x=a[0]
    for i in a[1:]:
        x^=i
    #print(x)
    ans=[]
    for i in a:
        ans.append(i^x)
    print(*ans)

Submission status: Accepted

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

buf = []
for i in a:
    buf.append(c^i)
    
print(*buf)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

A_max = max(A)
# A_str = format(A_max, "b")
# A_len = len(A_str)

# print("A_max: {} A_str: {} A_len: {}".format(A_max, A_str, A_len))
# format_opt = "0{}b".format(A_len)
# print("format_opt: {}".format(format_opt))
mask = 0
for a in A:
    mask = mask ^ a
# print(mask)

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

print(*ans)

Submission status: Accepted

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

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

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

res = 0
for a_ in a:
    res = a_ ^ res

for a_ in a:
    print(a_ ^ res, end=' ')
print()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    s = 0
    for i, aa in enumerate(a):
        if i == 0:
            s = aa
        else:
            s ^= aa
        # print(bin(s))

    ans = []
    if n % 2 == 0:
        for i, aa in enumerate(a):

            ans.append(s^aa)
    else:
        # print(bin(s))
        for i, aa in enumerate(a):

            ans.append(s^aa)
            # print(bin(ans[-1]))
    print(' '.join(map(str,ans)))

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
A_list = list(map(int,input().split()))
ans = []
total_xor = 0
for i in A_list:
  total_xor = int(str(bin(total_xor^i)),2)
total_xor = int(str(bin(total_xor^0)),2)
for i in A_list:
  print(int(str(bin(total_xor^i)),2),end=" ")

Submission status: Accepted

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


def cal_xor(xor_list):
    ans = None
    for xi in xor_list:
        if ans is not None:
            ans = ans^xi
        else:
            ans = xi
    return ans

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

ans_str = ''

if N==2:
    print("{} {}".format(a[1], a[0]))
else:

    xors = []
    for i in range(N//2):
        xors.append(a[2*i]^a[2*i+1])

    sum_xor = cal_xor(xors)
    for i, ai in enumerate(a):
        tmp_xor = sum_xor^xors[i//2]
        if i%2==0:
            ind = i+1
        else:
            ind = i-1

        ans = tmp_xor^a[ind]
        ans_str += str(ans)+' '
    print(ans_str[:-1])

Submission status: Accepted

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

for i in l:
    print(i,end=" ")

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
s = 0
for i in A:
    s = s ^ i
for i in A:
    print(s ^ i)

Submission status: Accepted

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

x = 0
for i in range(N):
  x ^= a[i]
l = [x^a[i] for i in range(N)]
print(*l)

Submission status: Accepted

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

B=[0]*N
for i in range(N):
    B[i]=s^A[i]

L=[str(a) for a in B]
L=" ".join(L)
print(L)

Submission status: Accepted

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

Submission status: Accepted

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

a = arr[0]

for i in range(1, n):
    a ^= arr[i]

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

Submission status: Accepted

Solution code:
from functools import reduce
from operator import xor
n = int(input())
A = list(map(int, input().split()))


total = []
it = iter(A)
for x, y in zip(it, it):
    total.append(x ^ y)

total = reduce(xor, total)

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

Submission status: Accepted

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

base = A[0]
for i in range(1, len(A)):
    base = base ^ A[i]

ans = [0] * N
for i, v in enumerate(A):
    ans[i] = str(base ^ v)

print(" ".join(ans))

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
ans=[[0]*30 for _ in range(N)]

if sum(a)==0:
    print(' '.join(['0']*N))
    exit(0)

i=29

while i>=0:
    curbit=[aa%2 for aa in a]

    s=sum(curbit)

    if s%2==0:
        for j in range(N):
            ans[j][i]=curbit[j]
    else:
        for j in range(N):
            ans[j][i]=0 if curbit[j] else 1



    a=[aa//2 for aa in a]
    
    i-=1

print(' '.join([str(int(''.join([str(aaa) for aaa in aa]),2)) for aa in ans]))

Submission status: Accepted

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

a = l[0]
for i in range(1, n):
    a = a ^ l[i]

for i in range(n):
    print(l[i]^a)

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
ans = [0] * N
a_max = max(a)
max_iter = len(bin(a_max)) - 2
i = 0
for i in range(max_iter+1):
    pow2 = 2 ** i
    count_1 = 0
    count_0 = 0
    for j in range(N):
        if a[j]>>i & 1:
            count_1 += 1
        else:
            count_0 += 1
            # ans[j] += 1 * pow2
    if count_1 % 2 == 0:
        #1 -> 1
        for j in range(N):
            if a[j]>>i & 1:
                ans[j] += 1 * pow2
    else:
        # 0-> 1
        for j in range(N):
            if not a[j]>>i & 1:
                ans[j] += 1 * pow2
print(*ans)

Submission status: Accepted

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

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

c = []
for i in range(n):
    num = samu^a[i]
    c.append(num)

print(*c)

Submission status: Accepted

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

import sys
import pprint

sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(1)
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	# b1 = a2 ^ a3 ^ a4
	# b1 ^ a2 = a3 ^ a4
	# b2 = a1 ^ a3 ^ a4
	# b2 ^ a1 = a3 ^ a4
	# b1 ^ a2 = b2 ^ a1
	# a1 = a3 ^ a4 ^ b2
	# b2 ^ a4 = b4 ^ a2
	# b2 = b4 ^ a2 ^ a4
	# a1 = b1 ^ b4 ^ a4
	# b1 = a1 ^ a2 ^ a3 ^ a4 ^ a1
	#    = b2 ^ a2 ^ a1
	#    = b2 ^ b3 ^ a4
	# a1 = b2 ^ b3 ^ b4
	sumxor = a[0]
	for i in range(1, n):
		sumxor ^= a[i]
	ans = []
	for i in range(n):
		ans.append(sumxor ^ a[i])
	print(*ans)

	


main()

Submission status: Accepted

Solution code:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

n = iinput()
a = iarr()
tmp = a[0]

for i in range(1,n): tmp = tmp^a[i]
anss = []
for i in range(n): anss.append(tmp^a[i])
print(*anss)

Submission status: Accepted

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

ans=[]
for i in a:
    ans.append(res^i)
print(*ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N = int(input())
    As = list(map(int, input().split()))

    digits = dict()
    for d in range(30):
        digits[d] = 0
        for a in As:
            digits[d] += a >> d & 1

    oore = 0
    for k, v in digits.items():
        oore += (v % 2) << k

    nums = [0] * N

    for i, a in enumerate(As):
        nums[i] = a ^ oore

    return nums


def main():
    print(*solve())


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from operator import mul

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

MAX_VAL = 10 ** 9

ans = []

for idx, a in enumerate(A[1:]):
    if idx == 0:
        xor = a
    else:
        xor ^= a

ans = [xor]

l_xor = None
r_xor = xor
for i in range(1, N):
    if i == 1:
        l_xor = A[i - 1]
        r_xor = A[i] ^ r_xor
        ans.append(l_xor ^ r_xor)
    elif i == N:
        l_xor = l_xor ^ A[i - 1]
        ans.append(l_xor)
    else:
        l_xor = l_xor ^ A[i - 1]
        r_xor = A[i] ^ r_xor
        ans.append(l_xor ^ r_xor)

print(*ans)

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
#print(bin(11^9^24))
B=bin(a[0])
for i in range(1,n):
    B=bin(int(str(B)[2:],2)^a[i])
for j in range(n):
    x=bin(int(str(B)[2:],2)^a[j])
    print(int(str(x)[2:],2))

Submission status: Accepted

Solution code:
input()
input_list = list(map(int,input().split()))
total = 0
for num in input_list:
    total = total ^ num
str_list = [str(num ^ total) for num in input_list]
print(" ".join(str_list))

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int,input().split()))
x = [0 for _ in range(31)]
for ai in a:
  i = 0
  while ai > 0:
    if ai%2 == 1:
      x[i] += 1
    ai = ai//2
    i += 1
for i in range(31):
  x[i] = x[i]%2
for ai in a:
  s = 0
  for i in range(31):
    if ai%2 == 1:
      if x[i] == 0:
        s += 2**i
    else:
      if x[i] == 1:
        s += 2**i
    ai = ai//2
  print(s)

Submission status: Accepted

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
N = int(input())
SUM = 0
A = []
O = []
for i in input().split():
  i = int(i)
  SUM ^= i
  A.append(i)

for a in A:
  O.append(SUM ^ a)

print(' '.join([str(s) for s in O]))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    hoge = [int(i) for i in input().split()]
    tmp = 0 
    for h in hoge:
        tmp = tmp ^ h
    res = [str(tmp ^ h) for h in hoge]
    print(' '.join(res))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import deque
def calcXor(nums):
  x=0
  for n in nums:
    x=x^n
  return x

N=int(input())
A=list(map(int,input().split()))
A_xor=calcXor(A)

ans=deque()
for a in A:
  ans.append(A_xor^a) 

#for i in range(N):  
  #print(A[0:i])
  #x=calcXor(A[0:i])
  #print(A[i+1:N])
  #y=calcXor(A[i+1:N])
  #ans.append(x^y)
print(" ".join(map(str,ans)))

Submission status: Accepted

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

for i in range(N):
  print(L^a[i])

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int,input().split()))
B = [0]*30
ans = []
for i in A:
    for j in range(30):
        if (i>>j) & 1:
            B[j] += 1
for i in A:
    C = [c for c in B]
    for j in range(30):
        if (i>>j) & 1:
            C[j] -= 1
    a = 0
    for j in range(30):
        if C[j]%2 == 1:
            a += 2**(j)
    ans.append(str(a))
print(" ".join(ans))

Submission status: Accepted

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
ans = []
s = 0
for x in a:
    s = s^x
for x in a:
    ans.append(x^s)
print(*ans)

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=a[0]
for i in range(N-1):
  b=b^a[i+1]
x=[0 for i in range(N)]
for i in range(N):
  x[i]=b^a[i]
x=map(str,x)
ans=' '.join(x)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
l = [0]*50
for s in A:
    b = list(bin(s))
    b = b[::-1]
    for ii, ss in enumerate(b):
        if ss == "b":
            break
        if ss == "1":
            l[ii] = (l[ii]+1) % 2
e = 1
num = 0
for i in range(50):
    num += l[i]*e
    e = e*2
for s in A:
    print(s ^ num)

Submission status: Accepted

Solution code:
def constructXOR(A, n): 
      
    # calculate xor of array 
    XOR = 0
    for i in range(0, n): 
        XOR ^= A[i] 
  
    # update array 
    for i in range(0, n): 
        A[i] = XOR ^ A[i] 

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

for i in range(0,n): 
    print(A[i], end =" ")

Submission status: Accepted

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

b = [0 for i in range(n)]

A = 0

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

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

Submission status: Accepted

Solution code:
from functools import reduce
N = int(input())
A = [int(x) for x in input().split(" ")]

S = reduce(lambda a, b: a ^ b, A)
B = [str(a ^ S) for a in A]
print(" ".join(B))

Submission status: Accepted

Solution code:
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
l=list(mi())
x=[1]*31
y=[[] for _ in range(a)]
for i in range(a):
  for j in range(31):
    if l[i]>>j & 1:
      x[j]=x[j]*(-1)
      y[i].append(-1)
    else:
      y[i].append(1)
c=0
for k in range(a):
  co=0
  for j in range(31):
    if x[j]!=y[k][j]:
      co+=2**j
  print(co,end=' ')

Submission status: Accepted

Solution code:
import collections
N = int(input())
A = list(map(int,input().split()))
S = collections.deque([])
for i in range(1,N):
    S.append(A[i]^A[i-1])
val = A[0]
for i in range(0,len(S),2):
    val = val^S[i]
T = [str(val)]
while len(S)>0:
    T.append(str(int(T[-1])^S.popleft()))
print(' '.join(T))

Submission status: Accepted

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

all_xor = a_list[0]
for i in a_list[1:]:
    all_xor ^= i

result = []
for i in a_list:
    result.append(all_xor ^ i)

print(*result)

Submission status: Accepted

Solution code:
import sys
import  math
import fractions
from collections import defaultdict
import heapq
from bisect import bisect_left,bisect

stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
A=nl()
keta=[0]*60
for i in A:
    for j in range(60):
        keta[j]+=((i>>j)&1)

ans_l=[0]*N
for i in range(N):
    for j in range(60):
        if(keta[j]%2!=(A[i]>>j)&1):
            ans_l[i]+=(1<<j)

print(*ans_l)

Submission status: Accepted

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

c = 0
for i in range(1,n):
    c ^= a[i]
    
for i in range(n):
    k = a[0] ^ a[i]
    print(k^c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
s = 0
for a in A:
    s ^= a
for a in A:
    print(s ^ a)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

class UnionFindEx:
    def __init__(self, size):
        #正なら根の番号、負ならグループサイズ
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   #負なら根
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    #サイズ更新
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N=ii()
    A = lmis()
    g = 0
    for a in A:
        g ^= a
    for a in A:
        print(g^a)



main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [[] for _ in range(n)]
c = [0]*30
d = []
for i in range(n):
    m = a[i]
    while m > 0:
        b[i].append(m%2)
        m //= 2
for i in range(n):
    for j in range(len(b[i])):
        c[j] += b[i][j]
for i in range(30):
    c[i] = c[i]%2
for i in range(n):
    e = 0
    for j in range(len(b[i])):
        if b[i][j]+c[j] == 1:
            e += 2**j
    for j in range(len(b[i]), 30):
        if c[j] == 1:
            e += 2**j
    d.append(e)
print(*d)