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: Wrong Answer

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

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def popcount(x):
    x = x - ((x >> 1) & 0x5555555555555555)

    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f 

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    l = len(bin(max(A))[2:])
    mask = int("1"*N, 2)
    for i in range(N):
        A[i] = list(bin(A[i])[2:].zfill(l))
    cols = [list(c) for c in zip(*A)]
    #print(A)
    #print(cols)
    colssum = [popcount(int("".join(c), 2)) for c in cols]
    for i in range(l):
        if (colssum[i]-int(cols[i][0])) % 2 == int(A[0][i]):
            cols[i] = "".join(cols[i])
        else:
            cols[i] = bin(int("".join(cols[i]), 2) ^ mask)[2:].zfill(N)
    #print(cols)
    ans = ["".join(a) for a in zip(*cols)]
    #print(ans)
    print(*(map(lambda x: int(x, 2), ans))) 
    


if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

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

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

print(X)

Submission status: Wrong Answer

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

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

ans = [0] * n
for i , j in enumerate(lis):
    ans[i] = t ^ j

print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
l = [0] * n
ans = [0] * n

for i in range(n):
    l[i] = int(format(a[i], 'b'))

s = sum(l)
r = list(str(s))
r = [int(i) for i in r]
for i in r:
    if i % 2 == 0:
        i = 0
    else:
        i = 1

r = map(str, r)
t = int(''.join(r))
for i in range(n):
    l[i] += t

for i in range(n):
    l[i] = list(str(l[i]))
    for j in range(len(l[i])):
        l[i][j] = int(l[i][j])

for i in range(n):
    for j in range(len(l[i])):
        if l[i][j] % 2 == 0:
            l[i][j] = 0
        else:
            l[i][j] = 1

for i in range(n):
    l[i].reverse()
    for j in range(len(l[i])):
        ans[i] += l[i][j] * 2 ** j

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

Submission status: Wrong Answer

Solution code:
#排他的論理和 x^y
n=int(input())
a=list(map(int,input().split()))

for i in range(0,n-1,2):
  #kはa_1 xor a_2を表す。
  k=a[i]^a[i+1]
  print(k,end=" ")
  print(0,end=" ")

Submission status: Wrong Answer

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

ans = 0
for a in A:
    ans ^= a
print(ans)
for a in A:
  	print(ans^a)

Submission status: Wrong Answer

Solution code:
N = int(input())
a_list = list(map(int, input().split()))
all_xor = 0
res = []

for a in a_list:
    all_xor ^= a

for a in a_list:
    res.append(a ^ all_xor)

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import log2
K = None

def find_kai(a, kai):
    for k1 in kai[::-1]:
        for k2 in kai[::-1]:
            n = []
            for i in range(len(k1)):
                n.append(k1[i]^k2[i])
            if a==n[::-1]:
                ans1 = 0
                ans2 = 0
                for k in range(len(n)):
                    ans1 += k1[k]*pow(2, k)
                    ans2 += k2[k]*pow(2, k)
                print(0, ans1, ans2)
                return

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    A_bin = []
    for a in A:
        a_bin = list(map(int, list(format(a, 'b'))))
        A_bin.append(a_bin)
    for a in A_bin:
        K = len(a)
        max_N = pow(2, K)
        kai = []
        for i in range(max_N):
            n = list(map(int, list(format(i, 'b'))))
            for j in range(K-len(n)):
                n.insert(0, 0)
            kai.append(n)
        find_kai(a, kai)

Submission status: Wrong Answer

Solution code:
from math import log2
K = None

def find_kai(a, kai):
    for k1 in kai[::-1]:
        for k2 in kai[::-1]:
            n = []
            for i in range(len(k1)):
                n.append(k1[i]^k2[i])
            if a==n:
                ans1 = 0
                ans2 = 0
                for k in range(len(n)):
                    ans1 += k1[k]*pow(2, k)
                    ans2 += k2[k]*pow(2, k)
                print(0, ans1, ans2)
                return

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    A_bin = []
    for a in A:
        a_bin = list(map(int, list(format(a, 'b'))))
        A_bin.append(a_bin)
    for a in A_bin:
        K = len(a)
        max_N = pow(2, K)
        kai = []
        for i in range(max_N):
            n = list(map(int, list(format(i, 'b'))))
            for j in range(K-len(n)):
                n.insert(0, 0)
            kai.append(n)
        find_kai(a, kai)

Submission status: Wrong Answer

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

b = [0]*N

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

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

Submission status: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline
import itertools
import collections
from decimal import Decimal
from functools import reduce


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n = int(input())
    numbers = input_list()
    ans = []
    for i in range(n):
        ans.append(reduce(lambda a, b: a ^ b, numbers))
    print(*ans)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def bfs(H, W, black_cells, dist):
    d = 0
    while black_cells:
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:
                dist[new_h][new_w] = d + 1
                black_cells.append((new_h, new_w))
    return d


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


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline
import itertools
import collections
from decimal import Decimal
from functools import reduce


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    n = int(input())
    numbers = input_list()
    ans = []
    for i in range(n):
        t = numbers[:]
        t.pop(i)
        ans.append(reduce(lambda a, b: a ^ b, t))
    print(ans)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def bfs(H, W, black_cells, dist):
    d = 0
    while black_cells:
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:
                dist[new_h][new_w] = d + 1
                black_cells.append((new_h, new_w))
    return d


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


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

B=[reduce(lambda a, b: a^b, A[:i]+A[(i+1):]) for i in range(N)]
print(B)

Submission status: Wrong Answer

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

num_list = []
s = 0
for i in range(n):
  num = numbers[i]
  num_str = ''
  if num == 0:
    num_str = str(num)
  while num != 0:
    p = num % 2
    num_str = str(p) + num_str
    num = num // 2
  #print(num_str)
  num = int(num_str)
  s += num
  num_list.append(num)
#print(s)
#print(num_list)
ans = []
for i in range(n):
  num = s - num_list[i]
  num = str(num)
  l = len(num)
  m = 0
  for j in range(l):
    k = num[j]
    k = int(k) % 2
    m += k * 2 ** (l - j - 1)
  ans.append(str(m))
print(' '.join(ans))

Submission status: Wrong Answer

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

num_list = []
s = 0
for i in range(n):
  num = numbers[i]
  num_str = ''
  if num == 0:
    num_str = str(num)
  while num != 0:
    p = num % 2
    num_str = str(p) + num_str
    num = num // 2
  #print(num_str)
  num = int(num_str)
  s += num
  num_list.append(num)
print(s)
print(num_list)
ans = []
for i in range(n):
  num = s - num_list[i]
  num = str(num)
  l = len(num)
  m = 0
  for j in range(l):
    k = num[j]
    k = int(k) % 2
    m += k * 2 ** (l - j - 1)
  ans.append(str(m))
print(' '.join(ans))

Submission status: Wrong Answer

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

b = a[0]
for v in a[1:]:
    b ^= v
for v in a:
    print(v ^ b)
print(*map(lambda x: x ^ b, a))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N == 2:
  print(a[1],a[0])
  exit()
for i in range(N):
  if i+3 < N:
    print(a[i+1]^a[i+2]^a[i+3],end = " ")
  else:
    print(a[i-1]^a[i-2]^a[i-3],end = " ")

Submission status: Wrong Answer

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

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

print(xor_a)

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

print(*ans)

Submission status: Wrong Answer

Solution code:
def computeXOR(n) : 
  
    # Modulus operator are expensive  
    # on most of the computers. n & 3  
    # will be equivalent to n % 4. 
  
    # if n is multiple of 4  
    if n % 4 == 0 : 
        return n 
  
    # If n % 4 gives remainder 1 
    if n % 4 == 1 : 
        return 1
  
    # If n%4 gives remainder 2  
    if n % 4 == 2 : 
        return n + 1
  
    # If n%4 gives remainder 3 
    return 0


def solve(A,n,x2): 
     
    x1 = A
    return x1 ^ x2

N = int(input())
q = [int(x) for x in input().split()]
x2 = computeXOR(N)
for ele in q:
    miss = solve(ele, N, x2) 
    print(miss, end=' ')
print('')

Submission status: Wrong Answer

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

m = max(a)
ans = [0] * n
z = 1
while True:
  b = False
  for i in range(n):
    if a[i] & z:
      b = not b
  for i in range(n):
    if b:
      if a[i] & z:
        ans[i] |= z
    else:
      if not (a[i] & z):
        ans[i] |= z

  z <<= 1
  if z > m:
    break

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

Submission status: Wrong Answer

Solution code:
#5
import numpy as np
N = int(input())
A = list(map(int, input().split()))
ai=0
a = np.array([])
num = 0# 各桁の1の個数を保存するリスト
bino = np.zeros(30)# Sの２進数表記の各桁をリストにしたもの
bi=[0]*N #bi = S+ai
b=[]#答えを格納
#aiを２進数に変換
for i in range(N):
    ai = list(map(int,list(format(A[i],'b'))))
    ai = np.array([0]*(30-len(ai)) + ai)#10の9乗は2の30乗で表せる
    a = np.append(a, ai,axis = 0 )
a = a.reshape(N, 30)
# 各桁の1の個数を保存するリスト
print(a)
num = a.sum(axis=0)
print(num)
#Sに変換
for i in range(len(num)):
    if num[i]%2==1:
        bino[i]=1
    else:
        bino[i]=0

#答えの２進数表記（各桁はリスト）
for i in range(N):
    bi = a[i] + num
    for j in range(30):#30回
        if bi[j]%2==1:
            bi[j]=1
        else:
            bi[j]=0
    b.append(list(map(str,list(map(int,bi)))))

print(b)
#10進数に変換
answer_bi = 0
for i in range(len(b)):
    answer_bi = "".join(map(str,b[i]))
    b[i] = int(answer_bi,2)


print(b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int, input().split())
total = 0
for a in A:
  total ^= a
result = []
for a in A:
  result.append(total ^ a)
print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
bina = []
for k in range(N):
    bina.append(str(bin(a[k]))[2:])
#print(bina)
A = ""
longest = len(bina[a.index(max(a))])
for k in range(1, longest+1):
    foo = 0
    for j in range(N):
        if len(bina[j]) >= k:
            foo += int(bina[j][-k])
    foo = foo*(N-1)
    foo = foo%2
    A = str(foo) + A
#print(A)
ans = ["" for k in range(N)]
#binans = []
for k in range(N):
    for j in range(1, len(bina[k])+1):
        if bina[k][-j] != A[-j]:
            ans[k] = "1" + ans[k]
        else:
            ans[k] = "0" + ans[k]
    #binans.append(bin(ans[k])[2:])
    ans[k] = str(int(ans[k], 2))
#print(binans)
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
bina = []
for k in range(N):
    bina.append(str(bin(a[k]))[2:])
#print(bina)
A = 0
b = 1
longest = len(bina[a.index(max(a))])
for k in range(1, longest+1):
    foo = 0
    for j in range(N):
        if len(bina[j]) >= k:
            foo += int(bina[j][-k])
    foo = foo%2
    foo = foo*b
    A += foo
    b = b*2
A = str(bin(A))[2:]
if longest > len(A):
    A = "0"*(longest-len(A)) + A
#print(A)
ans = [0 for k in range(N)]
#binans = []
for k in range(N):
    b = 1
    for j in range(1, len(bina[k])+1):
        if bina[k][-j] != A[-j]:
            ans[k] += b
        b = b*2
    #binans.append(bin(ans[k])[2:])
    ans[k] = str(ans[k])
#print(binans)
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
bina = []
for k in range(len(a)):
    bina.append(str(bin(a[k]))[2:])
#print(bina)
A = 0
b = 1
longest = len(bina[a.index(max(a))])
for k in range(1, longest+1):
    
    foo = 0
    for j in range(len(a)):
        if len(bina[j]) >= k:
            foo += int(bina[j][-k])
    foo = foo%2
    foo = foo*b
    A += foo
    b = b*2
A = str(bin(A))[2:]
if longest > len(A):
    A = "0"*(longest-len(A)) + A
#print(A)
ans = [0 for k in range(len(a))]
binans = []
for k in range(len(a)):
    b = 1
    for j in range(1, len(bina[k])+1):
        if bina[k][-j] != A[-j]:
            ans[k] += b
        b = b*2
    binans.append(bin(ans[k])[2:])
#print(binans)
print(ans)

Submission status: Wrong Answer

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

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

ans = a[:]
for i in range(N):
  ans[i] ^= tmp
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = [sum(a) ^ a[x] for x in range(N)]
print(' '.join(map(str, b)))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
#xor_a = [bin(x) for x in a]
#print(xor_a)
b = [sum(a) ^ a[x] for x in range(N)]
#b = [sum(a) ^ x for x in a]　でもいける
print(' '.join(map(str, b))) #' 'joinにより空白を間にいれる。mapにより文字列に直す

Submission status: Wrong Answer

Solution code:
#N = int(input())
a = list(map(int,input().split()))
#xor_a = [bin(x) for x in a]
#print(xor_a)
#sum_xor = bin(sum(a))
b = [sum(a) ^ a[x] for x in range(len(a))]
print(b)

Submission status: Wrong Answer

Solution code:
def main() -> None:
    N = ri()
    a = rmi()
    assert len(a) == N
    result = []
    all_xor = 0
    for item in a:
        all_xor ^= item
    for item in a:
        result.append(item ^ all_xor)
    wm(result)


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> tuple:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(*data, delim: str = ' ') -> None:
    print(delim.join(map(str, data)))


if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10 ** 9)
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
aaa = list(map(int, input().split()))
bbb = list(aaa[i] ^ aaa[i+1] for i in range(N-1))
ans = [0] * N
ans[0] = 1
for i, b in enumerate(bbb):
    ans[i+1] = b ^ ans[i]
print(*ans,sep=' ')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))
s = 0
for a in A:
  s ^= a
ans = ""
for a in A:
  ans = str(s ^ a) + " " + ans
print(ans)

Submission status: Wrong Answer

Solution code:
def addZero(tar,rep):
    for i in range(rep):
        tar = '0'+ tar
    return tar
# 整数の入力
N = int(input())
A = [bin(int(a)) for a in input().split()]
A = [v[2:] for v in A]
num_list = ['0b']*N
max_num = max(A)
max_len = len(max_num)
max_index = A.index(max_num)
for i in range(len(A)):
    r = max_len - len(A[i])
    if r>0:
        A[i] = addZero(A[i],r)
each = []
each_append = each.append
for i in range(max_len):
    one = 0
    for v in A[1:]:
        one += int(v[i])
    one = one%2
    if one==0:
        num_list[0] += '0'
    else:
        num_list[0] += '1'

    for t,v in enumerate(A[1:],1):
        if v[i] == A[0][i]:
            num_list[t] += str(one)
        else:
            if one==0:
                num_list[t] += '1'
            else:
                num_list[t] += '0'

result = [int(s,0) for s in num_list]
for num in result:
    print(num, end=' ')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
xor_arr = list(map(int, input().split()))
xor_of_xor = 0
for elm in xor_arr:
    xor_of_xor = xor_of_xor ^ elm
scarf_val = [xor_of_xor ^ elm for elm in xor_arr]

print(scarf_val)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
l = [0] * 30
b = []
for i in range(n):
  x = a[i]
  t = ''
  j = 29
  while j >= 0:
    if x < 2**j:
      t += '0'
    else:
      x -= 2**j
      t += '1'
      l[j] += 1
    j -= 1
  b.append(t)
ans = []
for i in range(n):
  t = b[i]
  d = 0
  for j in range(30):
    k = l[j]
    if t[j] == '1':
      k += 1
    k %= 2
    d += k * 2**j
  ans.append(d)
print(*ans)

Submission status: Wrong Answer

Solution code:
def bi(x):
  i = 29
  t = ''
  while i >= 0:
    if 2**i > x:
      t += '0'
    else:
      x -= 2**i
      t += '1'
    i -= 1
  return t

n = int(input())
a = list(map(int, input().split()))
l = [0] * 30
for i in range(n):
  for j in range(30):
    if bi(a[i])[j] == '1':
      l[j] += 1
      l[j] %= 2
ans = []
for i in range(n):
  x = 0
  for j in range(30):
    k = l[j]
    if bi(a[i])[j] == '1':
      k += 1
      k %= 2
    x += k * 2**j
  ans.append(x)
print(*ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np
input = sys.stdin.readline
n=int(input())
A =  list(map(int,input().split()))
B = []
ans = A[0]
for i in range(1,n):
    ans = ans ^ A[i]

for i in range(n):
    B.append(ans ^ A[i])
print(B)

Submission status: Wrong Answer

Solution code:
def bi(x):
  i = 29
  t = ''
  while i >= 0:
    if 2**i > x:
      t += '0'
    else:
      x -= 2**i
      t += '1'
    i -= 1
  return t

def xor(x, y):
  d = 0
  for j in range(30):
    if bi(x)[j] == '1' and bi(y)[j] == '0':
      d += 2**j
    elif bi(x)[j] == '0' and bi(y)[j] == '1':
      d += 2**j
  return d

n = int(input())
a = list(map(int, input().split()))
all_xor = 0
for i in range(n):
  all_xor = xor(a[i], all_xor)
l = []
for i in range(n):
  x = xor(all_xor, a[i])
  l.append(x)
print(*l)

Submission status: Wrong Answer

Solution code:
from functools import reduce
def resolver(N, A):
    X = reduce(int.__xor__, A)
    ans = [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(ans)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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(xor ^ a)
print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = []
max_length = len('{:b}'.format(max(a)))
for i in range(n):
    bit = '{:b}'.format(a[i]).rjust(max_length, '0')
    num = 0
    for j in range(max_length):
        if bit[j] == '0':
            num += pow(2, max_length - j - 1)
    ans.append(num)
for i in range(n):
    print(ans[i])

Submission status: Wrong Answer

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(19):
            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: Wrong Answer

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(18):
            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: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
b = [a[i]^a[i+1] for i in range(n-1)]
res = [26]
for i in range(n-1):
    res.append(res[-1]^b[i])
print(*res)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
b = [a[i]^a[i+1] for i in range(n-1)]
res = [0]
for i in range(n-1):
    res.append(res[-1]^b[i])
print(*res)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=(int(i) for i in input().split())
b=0
for i in a:b^=i
print(*(i^b for i in a))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
xor = 0
for a in A:
    xor ^= a
for a in A:
    for i in range(20):
        if xor >> i & 1:
            a ^= 1 << i
    print(a, "", end="")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
xor = 0
for a in A:
    xor ^= a
for a in A:
    ans = 0
    for i in range(20):
        if a >> i & 1:
            ans |= 1 << i
    print(ans, "", end="")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
ans = list()
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            ans.append(A[i]^A[j]^A[k])
print(*ans[::-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
ans = list()
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            ans.append(A[i]^A[j]^A[k])
print(*ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
A.append(A[0])
B=[]
C=[]

def xor(C):
  total=0
  for i in range(1,len(C)):
    total^=C[i]
  return total

for i in range(n):
  B.append(A[i]^A[i+1])

for i in range(1,100000):
  C.append(i)
  p=i
  for j in range(n-1):
    C.append(B[j]^p)
    p^=B[j]
  if xor(C)==A[0]:
    break
  else:
    C.clear()

C=[str(i) for i in C]
print(' '.join(C))

Submission status: Wrong Answer

Solution code:
sumlist=[0 for _ in range(30)]
N=int(input())
A=list(map(int,input().split()))
for j in A:    
    bi = format(j, 'b')
    for i in range(len(bi)-1,-1,-1):
        k=int(bi[i])
        sumlist[len(bi)-i-1]+=k
ans="0"
for i in range(29,-1,-1):
    ans+=str(sumlist[i])
s=int(ans)
ans_list=[]
for i in A:
    bi = format(i, 'b')
    m=s-int(bi)
    m=str(m)
    newans="0"
    for j in m:
        if int(j)%2==0:
            j=0
        else:
            j=1
        newans+=str(j)
    bin_num = int(newans, 2)
    ans_list.append(bin_num)
L=ans_list
L=[str(a) for a in L]
L=' '.join(L)
print(L)

Submission status: Wrong Answer

Solution code:
input()
print(input())

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
A.append(A[0])
B=[]
C=[]

def xor(C):
  total=0
  for i in range(1,len(C)):
    total^=C[i]
  return total

for i in range(n):
  B.append(A[i]^A[i+1])

for i in range(1,100000):
  C.append(i)
  p=i
  for j in range(n-1):
    C.append(B[j]^p)
    p^=B[j]
  if xor(C)==A[0]:
    break
  else:
    C.clear()

print(C)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(N):
    xor = 0
    for j in range(N):
        if i == j:
            xor ^= a[j]
    ans.append(xor)
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = []
Ans = [1]
for a1, a2 in zip(A, A[1:]):
    B.append(a1 ^ a2)
B.append(A[0] ^ A[-1])

for b in B:
    Ans.append(Ans[-1] ^ b)

for a in Ans[:-2]:
    print(a, end=' ')
print(Ans[-2])

Submission status: Wrong Answer

Solution code:
def xor(x):
    for i in range(len(x)-1):
        x[i+1]=x[i]^x[i+1]
    return x[len(x)-1]
N=int(input())
a=list(map(int,input().split()))
num=xor(a)
for i in range(N):
    A=[num,a[i]]
    print(xor(A),end=" ")

Submission status: Wrong Answer

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

s = 0
for i in range(N):
    s ^= A[i]
    print(s)
for i in range(N):
    ans = s^A[i]
    print(ans, end=" ")

Submission status: Wrong Answer

Solution code:
num = int(input())
a_i = list(map(int, input().split()))
s = 0
for x in a_i:
    s ^= x
ans = []
for x in a_i:
    ans.append(x ^ s)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int, input().split())
ax = 0
ans = []
for a in A:
  ax ^= a
for a in A:
  ans.append(a^ax)
  
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = list(map(int,input().split()))
di= [0]*n
for i in range(n):
    di[i] = int(bin(ls[i])[2:])
    if i == 0:
        s = di[i]
    else:
        s = s ^ di[i]
s = sum(di)
fi = list(str(s))
for j in range(len(str(s))):
    if int(fi[j]) % 2 == 0:
        fi[j] = 0
    else:
        fi[j] = 1
fi = list(map(str,fi))
ss = int("".join(fi))
pi = []
for k in di:
    a = ss+k
    b = list(str(a))
    for j in range(len(str(a))):
        if int(b[j]) % 2 == 0:
            b[j] = 0
        else:
            b[j] = 1
    c = list(map(str,b))
    pi.append(int("".join(c),2))
print(*pi)