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 sys, math


if(__name__ == "__main__"):
    """

    元の数biを求めるにはxor_all= a1^a2^a3^...^an
    を求め、
    b1=xor_all^a1, b2 = xor_all^a2, ...とする。Nが偶数なので
    xor_all = b1^b2^...^bnと等しい(xorの性質よりx^a^a = xとなるので)
    xor_allにaiをかけるとちょうどbiだけ残る
    """
    N = int( input().strip() )
    xors = [0] * N
    Str = input().strip().split()
    for i in range(N):
        xors[i] = int( Str[i] )
    xor_all = xors[0]
    for i in range(1, N):
        xor_all = xor_all ^ xors[i]
    nums = [0] * N

    Str = ""
    for i in range(N):
        nums[i] = xor_all^xors[i]
        Str += str(nums[i]) + " "
    
    print(Str)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from collections import defaultdict

N = int(input())  # 偶数
A = list(map(int, input().split()))
xorA = A[0]
for i in range(1, N):
    xorA = xorA ^ A[i]

ans = []
for i in range(N):
    res = xorA ^ A[i]
    res = int(res)
    ans.append(str(res))

print(" ".join(ans))

Submission status: Accepted

Solution code:
n=int(input())
a=input().split()
nl=[]
jo=0
for i in range(n):
  nl.append(int(a[i]))
  jo=jo^int(a[i])

for i in range(n):
  ans=nl[i]^jo
  print(ans,end=" ")
print("")

Submission status: Accepted

Solution code:
import numpy as np
def resolve():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = ""

    for n in range(len(bin(max(A))) - 1, -1 ,-1 ):
        ans += str(np.count_nonzero((A >> n)&1) % 2)
    for i in range(N):
        print(int(ans,2) ^ A[i], end =" ")
resolve()

Submission status: Accepted

Solution code:
n  = int(input())
a = [int(x) for x in input().split()]
s = a[0]
for i in range(1, n):
    s = s ^ a[i]

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

Submission status: Accepted

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

Aall = 0  
for i in range(N):
  Aall ^= A[i]
#
ans = ""
for i in range(N):
  ans += str( Aall ^ A[i] ) + " "
#
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
num = 30
list_a = [[0]*num for i in range(n)]
list_ans = []
for i in range(n):
    count = 0
    j = a[i]
    while j>0:
        list_a[i][count]=j%2
        j = j//2
        count+=1
list_sum = []
for i in range(num):
    su = 0
    for j in range(n):
        su+=list_a[j][i]
    list_sum.append(su%2+2)
for i in range(n):
    ans = 0
    for j in range(num):
        k = list_sum[j]
        list_a[i][j] -=list_sum[j]
        list_a[i][j]%=2
for i in range(n):
    wa = 0
    for j in range(num):
        wa+= (list_a[i][j]*pow(2,j))
    list_ans.append(wa)
print(" ".join(map(str,list_ans)))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    # jibun igai no xor = ai
    tot = 0
    for i in range(n):
        tot ^= a[i]
    res = [0]*n
    for i in range(n):
        res[i] = tot ^ a[i]
    print(*res)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    _ = int(input())
    A = list(map(int, input().split()))

    allXOR = 0
    for a in A:
        allXOR = allXOR ^ a  # 全てのスカーフの論理和

    R = []
    for a in A:
        R.append(a ^ allXOR)

    print(*R)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import deque
from functools import reduce
n = int(input())
al = [int(i) for i in input().split()]
ad = deque(al)

num = reduce(lambda x, y: x ^ y, al)

num = num ^ al[0]
print(num)
pre = al[0]
for i in al[1:]:
  num = num ^ pre
  num = num ^ i
  print(num)
  pre = i

Submission status: Accepted

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

tot=0
for num in l:
	tot^= num

ans=[]

for num in l:
	ans.append(num^tot)

print(*ans)

Submission status: Accepted

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

xor = 0
for i in range(N):
  xor = xor ^ a[i]
  
ans = []
  
for i in range(N):
  ans.append(xor ^ a[i])
  
print(' '.join(map(str, ans)))

Submission status: Accepted

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

for i in range(N):
    tmp = s ^ a[i]
    ans.append(str(tmp))
    
ans = ' '.join(ans)    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int,input().split()))
b = 0
C = []

for a in A:
  b^=a

for a in A:
  C.append(a^b)

print(*C)

Submission status: Accepted

Solution code:
n = int(input())
alist = [int(s) for s in input().split(" ")]
asum = alist[0]
for a in alist[1:]:
  asum ^= a

import copy
a_ans = []
for i in range(n):
  asum ^= alist[i]
  a_ans.append(asum)
  asum ^= alist[i]
print(" ".join([str(a) for a in a_ans]))

Submission status: Accepted

Solution code:
n = int(input())
data = list(map(int, input().split()))
total = 0
for a in data:
    total ^= a
ans = [total^a for a in data]
print(' '.join(map(str, ans)))

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_list()

    sum_d = 0
    for num in num_list:
        sum_d ^= num

    ans_list = []
    for num in num_list:
        ans_list.append(sum_d ^ num)

    print(*ans_list)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input().strip()) 
a = [int(x.strip()) for x in input().strip().split(' ')]

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

b = []
for i in a:
  b.append(str(t ^ i))
print(' '.join(b))

Submission status: Accepted

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

l = 0
for i in a:
  l ^= i

for i in a:
  j = l ^ i
  print(j, end=' ')

Submission status: Accepted

Solution code:
_,*a = open(0).read().split()
x = eval("^".join(a))
for i in a:
    print(x^int(i),end=" ")

Submission status: Accepted

Solution code:
import glob
import os

bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:
    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index - 1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        N = int(self.input_data())
        a = list(map(int, self.input_data().split()))

        a2_sum = [0]*N

        for i in range(0, N, 2):
            a2_sum[i] = a[i] ^ a[i+1]

        source = 0
        for i in range(0, N, 2):
            source = source ^ a2_sum[i]

        for i in range(N):
            print(str(a[i]^source), end=' ')


solver = Solver(REL_PATH)
solver.exec_resolve()

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
k = len(bin(np.max(a)))-2

b = []
c = [0] * k
for aa in a:
    d = bin(aa)[2:]
    e = k-len(d)
    for i in range(len(d)):
        if d[i] == '1':
            c[e+i] += 1

xo = int(''.join(['1' if c[i] % 2 == 1 else '0' for i in range(k)]), 2)

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

Submission status: Accepted

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

AA = [0] * (N)
for i in range(N):
    AA[i] = list(format(A[i], 'b').zfill(42))

ans = [0] * 42
ma = 0
for i in range(N):
    AA[i].reverse()
    for j in range(len(AA[i])):
        ma = max(ma, j)
        ans[j] += int(AA[i][j])

ret = []
for i in range(N):
    temp = 0
    for j in range(ma):
        if (ans[j] + int(AA[i][j])) & 1 == 1:
            temp += 1 << j

    ret.append(temp)

print(*ret)

Submission status: Accepted

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

ans = a[0]
for i in range(1, N):
    ans = ans ^ a[i]

res = [0 for _ in range(N)]
for i in range(N):
    res[i] = ans ^ a[i]
    res[i] = str(res[i])

print(' '.join(res))

Submission status: Accepted

Solution code:

n = int(input())
a = list(map(int, input().split()))
dp = [0] * 31
ans = []

for i in a:
    num = format(i, 'b').zfill(31)
    for j in range(31):
        if num[j] == '1':
            dp[j] += 1

for i in a:
    x = 0
    num = format(i , 'b').zfill(31)
    for j in range(31):
        if int(dp[j] - int(num[j])) % 2 == 0:
            continue
        elif int(dp[j] - int(num[j])) % 2 == 1:
            x += 2 ** (30 - j)
    ans.append(x)

for i in ans:
    print(i, end=' ')

Submission status: Accepted

Solution code:
n = int(input())
al = list(map(int, input().split()))
zen = al[0]
for i, a in enumerate(al):
    if i == 0:
        pass
    else:
        zen ^= a
# print(''.join([a ^ zen for a in al]))
print(*[a ^ zen for a in al])

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    N = int(readline())  # 偶数
    A = list(map(int, readline().rstrip().split()))  # [自分以外の全ての整数のxor, ...]
    
    if N == 2:
        print(*A[::-1])
        return
    
    xor = []
    for i in range(N-1):
        xor.append(A[i] ^ A[i+1])  # a xor b, b xor c, c xor d ...
    
    # bを求める
    b = A[0]
    for i in range(2, N, 2):
        b ^= xor[i]
    
    # aを求める
    a = xor[0] ^ b

    # print(a, b)
    res = [a, b]
    pre = b

    # c以降を求める
    for x in xor[1:]:
        next = pre ^ x
        res.append(next)
        pre = next

    
    print(*res)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

swt=format(XOR, '030b')
#print(swt)
s=[]
for i in range(30):
    if swt[i]=="1":
        s.append(i)
        #print('here')
#print(s)
ans=[]

for i in range(n):
    temp=list(format(a[i], '030b'))
    for i in s:
        if temp[i]=="1":
            temp[i]="0"
        else:
            temp[i]="1"
    #print("0b"+"".join(temp))
    ans.append(int("".join(temp),2))

print(' '.join([str(n) for n in ans]))

Submission status: Accepted

Solution code:
n = int(input())

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

ans=0

for i in range(1,n):
	ans^=x[i]
ans2=ans^x[0]
y=[]
y.append(str(ans))
for i in range(1,n):
	t=ans2^x[i]
	y.append(str(t))
print(' '.join(y))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

temp = A[0]

for a in A[1:]:
    temp ^= a

print(*[a^temp for a in A])

Submission status: Accepted

Solution code:
import sys
import math as mt
input=sys.stdin.buffer.readline  
#t=int(input())
t=1
for __ in range(t):
    #n,k=map(int,input().split())
    n=int(input())
    l=list(map(int,input().split()))
    xori=0
    for i in l:
        xori^=i
    for i in l:
        print(xori^i,end=" ")

Submission status: Accepted

Solution code:
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
S= 0
for n in range(N):
  S = S^A[n]
  
ans = ''
for n in range(N):
  m = S^A[n]
  ans += str(m) + ' '

print(ans[:-1])

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]
res = []
for i in range(n):
    res.append(x^a[i])
print(*res)

Submission status: Accepted

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

xor = a[0]
for i in range(1,N):
    xor = xor ^ a[i]

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

Submission status: Accepted

Solution code:
bitsum = 0
ans = []
N = int(input())
num = list(int(x) for x in input().split())
for i in num:
    bitsum = bitsum ^ i
for i in num:
    ans.append(bitsum ^ i)
print(' '.join(map(str, ans)))

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest
import os
from operator import ixor
from functools import reduce

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    # 数値取得サンプル
    #   1行1項目 n = int(input())
    #   1行2項目 x, y = map(int, input().split())
    #   1行N項目 x = [list(map(int, input().split()))]
    #   N行1項目 x = [int(input()) for i in range(n)]
    #   N行N項目 x = [list(map(int, input().split())) for i in range(n)]

    # 文字取得サンプル
    #   1行1項目 x = input()
    #   1行1項目(1文字ずつリストに入れる場合) x = list(input())
    n = int(input())
    x = list(map(int, input().split()))

    aaa = x[0]
    for cnt, i in enumerate(x):
        if cnt == 0:
            continue
        aaa = ixor(aaa, i)

    ans = []
    for cnt, i in enumerate(x):
        ans.append(ixor(aaa, i))

    print(*ans)

# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """4
20 11 9 24"""
        output = """26 5 7 22"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()

Submission status: Accepted

Solution code:
N = int(input())

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

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

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

print(" ".join(str(_) for _ in ans))

Submission status: Accepted

Solution code:
n = int(input())
A = [int(x) for x in input().split()]
a1 = A[1]
if n > 2:
    for an in A[2:]:
        a1 = a1 ^ an
a_all = A[0] ^ a1
ans = str(a1)
for an in A[1:]:
    ans += ' ' + str(a_all ^ an)
print(ans)

Submission status: Accepted

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

sl = [0 for i in range(n+1)]
sr = [0 for i in range(n+1)]
ans = []

for i in range(1, n+1):
  sl[i] = sl[i-1] ^ a[i-1]
  sr[n-i] = sr[n-i+1] ^ a[n-i]

for i in range(n):
  ans.append(str(sl[i] ^ sr[i+1]))
  
print(" ".join(ans))

Submission status: Accepted

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

allxor = 0
for ai in ali:
    allxor = allxor ^ ai

for i in range(n):
    ans = allxor ^ ali[i]
    
    if i != (n-1):
        print(ans, end=" ")
    else:
        print(ans)

Submission status: Accepted

Solution code:
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n = INT()
a = LIST()

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

for i in range(n):
    print(res ^ a[i], end = " ")

Submission status: Accepted

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

for i in A:
    print(res ^ i)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


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


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]


N = z()
a = zz()
ans = []
all_xor = 0
for _a in a:
    all_xor ^= _a

for i in range(N):
    tmp = -(all_xor ^ (~a[i])) - 1
    ans.append(tmp)
print(*ans)
# i番目以外のxorの合計がai

Submission status: Accepted

Solution code:
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################

n = int(input())
arr = list(map(int, input().split()))
ans = []
temp = 0
for i in arr:
	temp^=i
for i in range(n):
	ans.append(temp^arr[i])
print(*ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

def ii():
    return int(input())

def main():
    N = ii()
    a = list(mi())
    t = a[0]
    for i in range(N-1):
        t ^= a[i+1]

    l = [t^a[i] for i in range(N)]
    print(' '.join(list(map(str, l))))
    


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#n,k=map(int,input().split())
from collections import defaultdict
from sys import stdout
n=int(input())
l=list(map(int,input().split()))
x=l[0]^l[1]
for i in range(2,n):
  x^=l[i]
for i in range(n):
  stdout.write(str(x^l[i])+' ')

Submission status: Accepted

Solution code:
N = int(input())
A_list = [int(e) for e in input().split()]

all_A_xor = A_list[0]
#print(A_list[0],bin(A_list[0]))

for i in range(1,N):
    #print(A_list[i],bin(A_list[i]))
    all_A_xor ^= A_list[i]

#print(all_A_xor,bin(all_A_xor))

ans = [A^all_A_xor for A in A_list]
print(' '.join(map(str, ans)))

Submission status: Accepted

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

all = AN[0]
for i in range(N-1):
    all = all ^ AN[i+1]

output = []
for A in AN:
    output.append(str(A ^ all))
print(" ".join(output))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
## coding: UTF-8

N = int(input())
A = list(map(int,input().split()))
C = [format(i,'b') for i in A]
#print(C)


length = 0
for i in range(N):
    length = max(length, len(C[i]))
#print(length)


#30桁あればよし
even = [True] * 31 #後ろから考えます
for i in range(N):
    pivot = C[i]
    char = []
    for j in range(len(pivot)):
        char.append(pivot[j])
    char = char[::-1]
    for j in range(len(char)):
        if(char[j] == '1'):
            even[j] = not(even[j])
    #print(char)
    #print(even)


#print()
#print()

#print(C)
for i in range(N):
    pivot = C[i]
    ret = []
    #print(pivot, length-len(pivot))
    for j in range(length - len(pivot)):
        ret.append('0')
    for j in range(len(pivot)):
        ret.append(pivot[j])
    C[i] = (''.join(ret))
    #print(C)
#print(C)    





#print()
#print()

ans = []
for i in range(N):
    ret = []
    pivot = C[i]
    pivot = pivot[::-1]
    for j in range(length):
        if(even[j]):
            ret.append(pivot[j])
        else:
            if(pivot[j] == '0'):
                ret.append('1')
            else:
                ret.append('0')
    ret = ret[::-1]
    #print(pivot, ret)
    ans.append(int(''.join(ret), 2))
    #print(ans)
#print(ans)

for i in range(N):
    print(ans[i], end=' ')
print()

Submission status: Accepted

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

ans= [0]*N
tmp = A[1]

for i in range(2,N):
    tmp = tmp^A[i]

ans[0]=tmp
print(ans[0])

for i in range(1,N):
    ans[i]=ans[i-1]^A[i-1]^A[i]
    print(ans[i])

Submission status: Accepted

Solution code:
#E

N=int(input())
a=list(map(int,input().split()))
b=[0]*N
for i in range(N-1):
    b[i]=a[i]^a[i+1]
b[-1]=a[-1]^a[0]
#print("b:",b)

ans=[0]*N
for i in range(1,N):
    ans[0] ^=a[i]
for i in range(1,N):
    ans[i]= ans[i-1]^b[i-1]

print(*ans)

Submission status: Accepted

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

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

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

print(*ans)

Submission status: Accepted

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

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

for i in range(N):
    mm = mm^A[i]
    print("{} ".format(mm), end="")
    mm = mm^A[i]

print()

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
num=a[0]
for i in range(1,n):
    num=num^a[i]
b=[]
for i in range(n):
    b.append(num^a[i])
print(' '.join(map(str, b)))

Submission status: Accepted

Solution code:
N = int(input())

def convert(x):
    return bin(int(x))

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

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

for a in A:
    print(int(k ^ a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*A = map(int, read().split())
    
    L = [A[0]]
    R = deque([A[-1]])

    for i in range(1,N):
        L.append(L[-1] ^ A[i])
        R.appendleft(R[0] ^ A[-(i+1)])

    ans = [R[1]]
    for i in range(1,N-1):
        ans.append(L[i-1] ^ R[i+1])
    ans.append(L[-2])

    print(*ans)



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
L=lmp()
l=[0]*n
ans=[0]*n
for i in range(n-1):
    l[i]=L[i]^L[i+1]
l[n-1]=L[n-1]^L[0]

if n==2:
    print(L[1],L[0])
    exit()
abc=L[3]
for i in range(4,n):
    abc=abc^L[i]
ans[0]=abc^l[1]
for i in range(1,n):
    ans[i]=ans[i-1]^l[i-1]
print(*ans)

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(' '.join([ str(s ^ a[i]) for i in range(N)]))

Submission status: Accepted

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

xor = a[0]
for i in range(1, N):
  xor = xor ^ a[i]

ans = []
for b in a:
  ans.append(xor ^ b)
print(*ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [int(x) for x in input().split()]

ans = 0
for i in range(n):
    ans = ans^a[i]
    
for i in range(n):
    print(ans^a[i], end=' ')

Submission status: Accepted

Solution code:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
n = int(input())
lin = [0 for i in range(n+1)]
ans = [0 for i in range(n)]
a = list(map(int, input().split()))
for i in range(n):
    lin[i + 1] = lin[i]^a[i]
#print(lin)
ans[n - 1] = lin[n - 1]
sumv = 0
for i in range(n-1, 0, -1):
    sumv ^= a[i]
    ans[i - 1] = lin[i - 1]^sumv
    #print(i, ': ', lin[i], sumv)
for x in ans:
    print(x, '', end='')
print()

Submission status: Accepted

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

all = 0
for a in a_list:
    all = all ^ a

for a in a_list:
    print(a ^ all, end=" ")
print()

Submission status: Accepted

Solution code:
import numpy as np
#from numba import njit

#(N, K) = map(int, input().split())
#A = np.array(list(map(int, input().split())))
N = int(input())
A = np.array(list(map(int, input().split())))

#@njit
def solve(N,A):
    l = []
    S = np.bitwise_xor.reduce(A)
    S = S ^ A[0]
    l += (str(S),)
    i = 1
    while i < len(A):
        S = S ^ A[i-1] ^ A[i]
        l += (str(S),)
        i+= 1
    print(" ".join(l))
        
solve(N,A)

Submission status: Accepted

Solution code:


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

    ans = []
    for a in al:
        curr_ans = all_xor ^ a
        ans.append(curr_ans)

    print(*ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

if __name__ == '__main__':
    n = int(sys.stdin.readline())
    A = list(map(lambda x: int(x), sys.stdin.readline().split()))
    allxor = 0
    for a in A:
        allxor ^= a
    for a in A:
        print(allxor^a, end=' ')
    print()

# スヌケ君dの値が知りたい：d以外の人の計算結果を全部xorする

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
a=list(map(bin, a))
b=list(map(len, a))
M=max(b)-2
for i in range(N):
    a[i] = '0'*(M-len(a[i])+2)+a[i][2:]
cnt = [0]*M

for i in range(N):
    for j in range(M):
        if a[i][j] == '1':
            cnt[j]+=1
for i in range(M):
    cnt[i]%=2
for i in range(N):
    ans=''
    for j in range(M):
        if int(a[i][j])!=cnt[j]:
            ans=ans+'1'
        else:
            ans=ans+'0'
    print(int(ans, 2), end=' ')

Submission status: Accepted

Solution code:
from sys import stdin

def main():

    input = stdin.readline

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

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

    ans_list = []
    for i in A:
        ans_list.append(a ^ i)

    print(*ans_list)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
a=list(map(int,input().split()))
p=0
for i in range(N):#O(200000)
  p=p^a[i]
#これでpは各猫のxorになったはず
ls=[]
for i in range(N):#O(200000)
  ls.append(p^a[i])
print(' '.join(map(str, ls)))

Submission status: Accepted

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

allbit = A[0]
for n in range(1,N):
  allbit = allbit ^ A[n]

ans = ["" for _ in range(N)]
for n in range(N):
  ans[n]= allbit ^ A[n]
  
print(*ans)

Submission status: Accepted

Solution code:
import sys
import numpy as np

readline = sys.stdin.readline

n = int(input())
a = np.array(readline().split(), dtype= np.int64)
x = np.bitwise_xor.reduce(a)
a ^= x
print(*a)

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:
N = int(input())
a = list(map(int,input().split()))

ans = []
ret = 0
for i in range(N):
    ret ^= a[i]

for i in range(N):
    temp = ret ^ a[i]
    ans.append(temp)
    
print(*ans)

Submission status: Accepted

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

def xor(x):
    r = 0
    for i in x:
        r ^= i
    return r

if __name__ == '__main__':
    main()

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]
ans=[]
for i in range(n):
  ans.append(s^a[i])
print(*ans)

Submission status: Accepted

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
L = 0
for a in A:
    L  ^=a
for a in A:
    print(L^a,end=" ")