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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    L = lmi()
    if n == 2:
        print(*reversed(L), sep=' ')
    else:
        ans = [0] * n
        for i in range(n):
            num = L[i] ^ (L[(i+1) % n] ^ L[(i+2) % n])
            ans[(i-1) % n] = num
            # print(ans)
        print(*ans, sep=' ')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def isp():   return input().split()
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    L = lmi()
    ans = [0] * n
    for i in range(n):
        num = L[i] ^ (L[(i+1) % n] ^ L[(i+2) % n])
        ans[(i-1) % n] = num
        # print(ans)
    print(*ans, sep=' ')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

N = i()
a = l()
A = 0
for i in range(N):
    A = A^a[i]
bit = bin(A)[2:]
n = len(bit)
bits = []
for i in range(N):
    bits.append(bin(a[i])[2:])
ans = []
maxlen = len(bin(max(a))[2:])
bit = list(bit.zfill(maxlen))[::-1]
for i in range(N):
    b = list(bits[i].zfill(maxlen))[::-1]
    num = 0
    print(bit,b)
    for j in range(maxlen):
        if bit[j] != b[j]:
            num += 2**j
    ans.append(num)
print(*ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s = 0
for i in lis:
    s = s^i
lis = list(map(lambda x: str(-(-s^x)), lis))
st = ' '.join(lis)
print(st)

Submission status: Wrong Answer

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

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

ans=[0]*n
for i in range(n):
    ans[i]=c^a[i]
L=[str(a) for a in ans]
L=" ".join(L)
print(L)

Submission status: Wrong Answer

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

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

All = ans[0]^A[0]

for i in range(N):
    ans[i] = All^A[i]

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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


def main():
    N = int(input())
    A = inpl()
    tmp = [0] * 19

    for a in A:
        for i in range(19):
            if (a >> i) % 2 == 1:
                tmp[i] = (tmp[i] + 1) % 2

    ans = []
    for a in A:
        b = 0
        for i in range(19):
            if tmp[i] == 0 and (a >> i) % 2 == 1:
                b += 2**i
            elif tmp[i] == 1 and (a >> i) % 2 == 0:
                b += 2**i
        ans.append(b)
    print(*ans)

    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

for a in A:
	ans += [str(a ^ s)]
print(' ' .join(ans))

Submission status: Wrong Answer

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


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


def main():
    N = int(input())
    A = inpl()
    tmp = [0] * 19

    for a in A:
        for i in range(19):
            tmp[i] = (tmp[i] + (a >> i) % 2) % 2

    ans = []
    for a in A:
        b = 0
        for i in range(19):
            if tmp[i] == 0 and (a >> i) % 2 == 1:
                b += 2**i
            elif tmp[i] == 1 and (a >> i) % 2 == 0:
                b += 2**i
        ans.append(b)
    print(*ans)

    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# ABC171 E 
# Python:AC , PyPy:TLE

import itertools

n = int(input())
a_l = [list(format(int(x), "029b")) for x in input().split()]

for _d,_tp in enumerate(zip(*a_l)):
    if "1" not in _tp:
        continue
    if "0" not in _tp:
        continue
    else:
        _num = _tp.count("0")
        if _num % 2 == 1:
            for i in range(n):
                if a_l[i][_d] == "0":
                    a_l[i][_d] = "1"
                else:
                    a_l[i][_d] = "0"

print(*[int("".join(x), 2) for x in a_l])

Submission status: Wrong Answer

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

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

for i in a:
    print(t ^ i)

Submission status: Wrong Answer

Solution code:
# ABC171 E 

import itertools

n = int(input())
a_l = [list(format(int(x), "030b")) for x in input().split()]

for _d,_tp in enumerate(zip(*a_l)):
    if "1" not in _tp:
        continue
    if "0" not in _tp:
        continue
    else:
        _num = _tp.count("0")
        if _num % 2 == 1:
            for i in range(n):
                if a_l[i][_d] == "0":
                    a_l[i][_d] == "1"
                else:
                    a_l[i][_d] == "0"

print(*[int("".join(x), 2) for x in a_l])

Submission status: Wrong Answer

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

b = [S^a for a in A]
print(b)

Submission status: Wrong Answer

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

lis = []
for a in A:
    S = 0
    i = 0
    for i in range(30):
        s = 0 | (a >> i)
        if i%2 == 0:
            if s == 1:
                S += 2**i
        else:
            if s == 0:
                S += 2**i
        i += 1
    lis.append(S)
print(*lis)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


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


n = I()
A = list(MI())

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

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

print(" ".join(ans[::-1]))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


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


n = I()
al = list(MI())

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

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

print(" ".join(ans[::-1]))

Submission status: Wrong Answer

Solution code:
N=int(input())
arr = list(map(int,list(input().split())))
ds = set(arr)
############################################

allxor=0
for i in range(N):
	if len(ds)==0:
		break
	allxor=allxor ^ ds.pop()
	#allxor=allxor ^ arr[i]

#for i in range(N):
#	print(allxor ^ arr[i],end='')
#	print(' ',end='')

for i in range(N):
	if i==0 :
		s=str(allxor ^ arr[i])
	else:
		s=s + ' ' + str((allxor ^ arr[i]))

print(s)

Submission status: Wrong Answer

Solution code:
def main():
  N=int(input())
  a=list(map(int,input().split()))
  p=max(a)
  m=len(bin(p))-2
  for i in range(N):
    b=len(bin(a[i]))-2
    ans=0
    for j in range(b):
      if a[i]>>j&1==1:
        if j==m-1 or j==0:
          ans+=pow(2,j)
      else:
        if j==m-1 or j==0:
          continue
        ans+=pow(2,j)
    print(ans,end=' ')
if __name__=='__main__':
  main()

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
a = np.fromstring(input(), sep=" ", dtype=np.int64)
b = np.bitwise_xor.reduce(a)
c = np.bitwise_xor(a, 0)
print(*c, sep=" ")

Submission status: Wrong Answer

Solution code:
N=int(input())
arr = list(map(int,list(input().split())))
ds = set(arr)
############################################

allxor=0
for i in range(N):
	if len(ds)==0:
		break
	allxor=allxor ^ ds.pop()
	#allxor=allxor ^ arr[i]

for i in range(N):
	#if i==0 :
	#	s=str(allxor ^ arr[i])
	#else:
	#	s=s + ' ' + str((allxor ^ arr[i]))
	print(allxor ^ arr[i],end='')
	print(' ',end='')

#print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
b = ["" for i in range(N)]

def int_to_2(X):
    r = ""
    while X>0:
        r = r + str(X%2)
        X = int((X- X%2)/2)
    return(r)

for i in range(N):
    b[i]=int_to_2(a[i])

def xor(aa,bb):
    rr = ""
    if len(bb) > len(aa):
        cc = bb
        bb = aa
        aa = cc
    for i in range(len(aa)-len(bb)):
        bb = bb + "0"
    for i in range(len(aa)):
        if aa[i]!=bb[i]:
            rr = rr + "1"
        else:
            rr = rr + "0"
    return(rr)

def bi_to_int(rr):
    r = 0
    for i in range(len(rr)):
        r = r + (2**i)*int(rr[i])
    return(r)

anss = ["" for i in range(N)]

for i in range(N-1):
    anss[0] = xor(anss[0],b[i+1])

for i in range(N-1):
    anss[i+1] = xor(anss[i],xor(b[i],b[i+1]))

writeout = ""

Submission status: Wrong Answer

Solution code:
N=int(input())
arr = list(map(int,list(input().split())))
ds = set(arr)
############################################

allxor=0
for i in range(N):
	if len(ds)==0:
		break
	allxor=allxor ^ ds.pop()
	#allxor=allxor ^ arr[i]

for i in range(N):
	if i==0 :
		s=str(allxor ^ arr[i])
	else:
		s=s + ' ' + str((allxor ^ arr[i]))

print(s)

Submission status: Wrong Answer

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

nl = []
for i in a:
    s = str(format(i, 'b'))
    for c in range(len(s)):
        if len(nl) > c:
            if s[len(s) - (c + 1)] == '1':
                nl[c] += 1
        else:
            if s[len(s) - (c + 1)] == '1':
                nl.append(1)
            else:
                nl.append(0)

ansl = []
for i in a:
    s = str(format(i, 'b'))
    ans = nl.copy()
    for c in range(len(s)):
        ans[len(s) - (c + 1)] -= int(s[c])
        if ans[len(s) - (c + 1)] % 2 == 0:
            ans[len(s) - (c + 1)] = 0
        else:
            ans[len(s) - (c + 1)] = 1
    p = 0
    for i in range(len(s)):
        p += ans[i] * 2 ** i
    ansl.append(p)

for i in range(len(ansl) - 1):
    print(ansl[i], end=' ')
print(ansl[len(ansl) - 1])

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


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


n = I()
al = list(MI())


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

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

print(" ".join(ans[::-1]))

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    a = list(map(int, input().split()))
    # 自分以外全体のxorがわかっている状態
    ans = [0]*N
    for i in range(5):
        c1 = 0
        for j in range(N):
            if (a[j]>>i)&1:
                c1+=1
        for j in range(N):
            if c1%2==0:
                ans[j] += ((a[j]>>i)&1)*pow(2,i)
            else:
                ans[j] += (not (a[j]>>i)&1)*pow(2,i)
    print(*ans)

main()

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


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


n = I()
al = set(MI())


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

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

print(" ".join(ans[::-1]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
maxa = 0
b = []
for j in range(n):
    maxa = max(maxa,a[j])
    b.append(int(str(bin(a[j]))[2:]))

bsum = sum(b)

c = []
d = []
for i in range(n):
    c.append(str(bsum - b[i]))

    for j in range(len(c[i])):
        if int(c[i][j]) % 2 == 0:
            c[i]= c[i][:j] + '0' + c[i][j+1:]
        else:
            c[i] = c[i][:j] + '1' + c[i][j+1:]
    d.append(int(c[i],2))

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

Submission status: Wrong Answer

Solution code:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np
import collections

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

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

ans = []
x1 = 10**9
ans.append(x1)

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[]
l=0
for i in range(n):
  t=list(bin(a[i]))
  l=max(l,len(t)-2)
  temp=0
  for j in range(2,len(t)):
    if t[j]=="0":
      temp=temp+2**(len(t)-j-1)
    tl=len(t)-2
  while tl<l:
    temp=temp+2**(l-(tl-l)-2)
    tl=tl+1
  ans.append(str(temp))
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

N = INT()
a = LIST()

if max(a) == 0:
	print(*[0]*N)
	exit()

n = ceil(log2(max(a)))

A = ["{:b}".format(x).zfill(n) for x in a]


b = a[0]
for i in range(1, N):
	b ^= a[i]
b = "{:b}".format(b).zfill(n)


ans = []

for x in A:
	tmp = 0
	for i in range(n):
		tmp += ((int(b[i])+int(x[i]))%2) * (2**(n-1-i))

	ans.append(tmp)

print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [bin(int(i)) for i in input().split(" ")]
max_len = len(str(max(a))[2:])

a = [str(i)[2:].zfill(max_len) for i in a]
count_list = []
for l in range(max_len):
    count_list.append(sum([int(one[l]) for one in a]))

answer_list = []
for k in range(n):
    string = ""
    for l in range(max_len):
        if (count_list[l] - int(a[k][l]))%2==0:
            string+="0"
        else:
            string+="1"
    answer_list.append(str(int("0b" + string, 0)))
print(" ".join(answer_list))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


def S():
    return input().rstrip()


def I():
    return int(input())


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


def func(l):
    ans = 0
    for ll in l:
        ans ^= ll
    return ans


n = I()
al = set(MI())

ans = []
for i in range(n):
    tmp = 0
    for j, a in enumerate(al):
        if i != j:
            tmp ^= a
    ans.append(str(tmp))

print(" ".join(ans[::-1]))

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n = ni()
a = nl()
for i,j in enumerate(a):
    if i == 0:
        t = i
        continue
    t = t ^ j
for k in a:
    print(t ^ k)

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
a = list(map(int, input().split()))
a = [format(i, '019b') for i in a]
ans = [''] * N
for i in range(19):
    tmp = [int(t[i]) for t in a]
    if Counter(tmp)[0] % 2 == 0:
        for j in range(N):
            ans[j] += str(tmp[j])
    else:
        for j in range(N):
            if tmp[j]:
                ans[j] += str(0)
            else:
                ans[j] += str(1)
ans_b = [int('0b'+tp, 0) for tp in ans]
print(' '.join(map(str, ans_b)))

Submission status: Wrong Answer

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

a0b=[0]*n
c=[0]*30
for i in range(n):
    a0b[i]=bin(a[i])
    st=str(a0b[i])
    for j in range(len(st)-2):
        z=a0b[i][-1-j]
        z=int(z)
        c[j]+=z

c_al=[0]*30
for i in range(len(c)):
    if c[i]%2==1:
        c_al[i]+=1

#c_alは全体の排他的論理和
ans=[0]*n
for i in range(n):
    st=str(a0b[i])
    for j in range(len(st)-2):
        if c_al[j]!=int(st[-1-j]):
            ans[i]+=2**(j)
L=[str(a) for a in ans]
L=" ".join(L)
print(L)

Submission status: Wrong Answer

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

for i in range(N):
    ans = 0
    for j in range(60):
        x = 0
        for k in range(N):
            if i == k:
                continue
            if A[k] >> j & 1:
                x += 1
        if x % 2 == 1:
            ans += 2**j
    print(ans, end = "")

Submission status: Wrong Answer

Solution code:
N=int(input())
a_list=list(map(int,input().split()))
a_list.sort(reverse=True)
c_list=[None]*N

c_list[0]=2**(len(bin(a_list[0])[2:]))-1
b=a_list[0]

for i,a in enumerate(a_list[1:]):
    print(bin(c_list[i]),bin(a))
    c_list[1+i]=b^a^c_list[i]
    b=a

ans=" ".join(list(map(str,c_list)))
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
p=[]
for j in range(30):
  p.append(pow(2,j))
t=0
for i in range(n):
  t=t^a[i]
  print(t)
for i in range(n):
  ans=0
  for j in range(30):
    ans=ans+p[j]*(((a[i]^t)//p[j])%2)
  print(ans,end=" ")

Submission status: Wrong Answer

Solution code:
from collections import Counter

N = int(input())
a = list(map(int, input().split()))
a = [format(i, '019b') for i in a]
ans = [''] * N
for i in range(19):
    tmp = [int(t[i]) for t in a]
    if Counter(tmp)[0] % 2 == 0:
        for j in range(N):
            ans[j] += str(tmp[j])
    else:
        for j in range(N):
            if tmp[j]:
                ans[j] += str(0)
            else:
                ans[j] += str(1)
ans_b = [int('0b'+tp, 0) for tp in ans]
print(ans_b)

Submission status: Wrong Answer

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

from itertools import combinations
  
perm = combinations(alist,len(alist)-1)

ans = []
for i in perm:
    xor = 0 
    for j in i:
        xor ^= j
    ans.append(xor)

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

Submission status: Wrong Answer

Solution code:
N = input()
strs = input().split(" ")
nums = list(map(int,strs ))
all = []
ma = max(nums)


ma_l = len(format(ma,"b"))
all_nums = [0] * ma_l



for num in nums:
    bins = format(num,"b")
    
    bins = bins[::-1]
    for i,c in enumerate(bins):
        if c == "1":
            all_nums[i] += 1

all_nums.reverse()
anss = []
for num in nums:
    s = num
    bins = format(num,"b")
    bins = bins[::-1]
    ans = 0
    jo  = 1
    for i in range(ma_l):
        
        if len(bins) - 1 < i:
            hoge = 0
        else:
            c = bins[i]
            hoge = int(c ) 
        if (all_nums[i] - hoge) % 2 == 1:
            ans += jo 
        jo *= 2
    anss.append(ans)
print(*anss)

Submission status: Wrong Answer

Solution code:
#5問目
N = int(input())
a = list(map(int, input().split()))
#XORはpythonでは^で表現
temp = 0
result = []
for i in range(N):
    for j in range(len(a)):
        if j != i:
            temp = temp ^ a[j]
    result.append(temp)
    temp = 0
print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())
a = list(map(int,input().split()))
matrix = [[0 for j in range(19)] for i in range(n)]
total = [0 for j in range(19)]
 
for j in range(n):
  target = a[j]
  for i in range(19):
    matrix[j][i] = a[j]//(2**(i))
    total[i] += a[j]//(2**(i))
    a[j] -= a[j]%(2**(i))

for k in range(19):
  total[k] = total[k]%2
  
for l in range(n):
  answer = 0
  for m in range(19):
    answer += (2**m)*((matrix[l][m]+total[m])%2)
  print(answer,end=" ")

Submission status: Wrong Answer

Solution code:
n=int(input())
A = list(map(int, input().split()))
A2=[0]*n
for a in range(n):
    flag=False
    ans = [0] * n
    ans[0]=a
    for i in range(1,n):
        x=a^A[0]^A[1]
        ans[i]=x
        if not 1<=ans[i]<=n:
            break
        if i==n-1:
            flag=True
            break
    if flag:
        break
for i in range(n):
    print(ans[i])

Submission status: Wrong Answer

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

xorhalf1=0
xorhalf2=0

for i in range(N//2):
	xorhalf1=xorhalf1^a_ls[i]
	xorhalf2=xorhalf2^a_ls[N-1-i]

ans1=""
ans2=""

for i in range(N//2):
	for j in range(i):
		xorhalf1=xorhalf1^a_ls[N//2+j]
		xorhalf2=xorhalf2^a_ls[j]
	
	
	for j in range(i+1,N//2):
		xorhalf1=xorhalf1^a_ls[N//2+j]
		xorhalf2=xorhalf2^a_ls[j]
	
	
	ans1+=" "
	ans1+=str(xorhalf2)
	ans2+=" "
	ans2+=str(xorhalf1)

print(ans1[1:]+ans2)


# 2darray [[0] * 4 for i in range(3)]

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    a = list(map(int, input().split()))
    # 自分以外全体のxorがわかっている状態
    ans = a
    for i in range(10):
        c0,c1 = 0,0
        for j in range(N):
            if (a[j]>>i)&1:
                c1+=1
        if c1%2==0:
            ans[j] += (a[j]>>i)*pow(2,i)
        else:
            ans[j] += (((a[j]>>i)+1)%2)*pow(2,i)
    print(*ans)

main()