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:
def main():
    n = int(input())
    a = list(map(int,input().split()))
    s = 0
    for i, aa in enumerate(a):
        if i == 0:
            s = aa
        else:
            s ^= aa
    ans = []
    if s % 2 == 0:
        for i, aa in enumerate(a):

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

            ans.append(~(s^aa))
    print(' '.join(map(str,ans)))

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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]
  print(S)
  
ans = ''
for n in range(N):
  m = S^A[n]
  ans += str(m) + ' '

print(ans)

Submission status: Wrong Answer

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

keta = len(bin(max(a))) - 2
tmp = [0] * keta
for i in a:
    for j, k in enumerate(bin(i)[2:][::-1]):
        tmp[j] += int(k)
tmp = tmp[::-1]

ans = [""] * n
for i in tmp:
    for j in range(n):
        if i > 0:
            ans[j] += "0"
            i -= 1
        else:
            ans[j] += "1"

ans_ = []
for i in ans:
    ans_.append(int(i, 2))
print(*ans_)

Submission status: Wrong Answer

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(ans)

Submission status: Wrong Answer

Solution code:
import math as mt
import collections as cc
I=lambda:list(map(int,input().split()))
n,=I()
l=I()
ll=0
te=[]
for i in l:
    x=format(i,'b')
    ll=max(ll,x[::-1].rfind('1'))
d=ll+1
to=[]
def ch(x):
    te=''
    for i in x:
        if i=='1':
            te+='0'
        else:
            te+='1'
    return int(te[::-1],2)
for i in l:
    print(format(i,'064b')[-d:])
    to.append(ch(format(i,'064b')[-d:]))
print(*to)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
ls = list(map(int,input().split()))
ans = ""
for i in range(N):
    if ls[-(i+1)] > N**2:
        ans += str(math.ceil(math.sqrt(N))+ls[-(i+1)])
    else:
        ans += str(ls[-(i+1)]-N)
    if i == N-1:
        break
    else:
        ans += " "
print(ans)

Submission status: Wrong Answer

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

b_ls=[0]*30
c_ls=[]

import numpy as np

for i in range(N):
	b=bin(a_ls[i])[2:].zfill(30)
	c_ls+=[list(b)]
	for j in range(30):
		b_ls[j]+=int(b[j])


for i in range(N):
	d_ls=np.array(b_ls)-np.array(c_ls[i]).astype(int)
	print(d_ls)
	ans=0
	for i in range(30):
		ans+=(d_ls[29-i]%2)*(2**i)
	
	print(ans)


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

Submission status: Wrong Answer

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

m = bin(10**9)[2:]

first = ''

for (i, a) in enumerate(A):
    if i == 0:
        first = a
        print(0)
        continue
    else:
        xor = first^a
        print(xor)

Submission status: Wrong Answer

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

while True:
    curbit=[aa%2 for aa in a]

    s=sum(curbit)

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

    if s==0:
        break
    
    a=[aa//2 for aa in a]
    i-=1

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

Submission status: Wrong Answer

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

ma = max(a)
tmp = 1
m = 0
while True:
    if tmp >= ma:
        break
    tmp *= 2
    m += 1

memo = [0 for i in range(m)]

for j in range(m):
    cnt0 = 0
    cnt1 = 0
    for ai in a:
        if ai & (1 << j):
            cnt1 += 1
        else:
            cnt0 += 1
    if cnt1 % 2 == 0 and cnt0 % 2 == 0:
        memo[j] = 1

ans = []

for ai in a:
    ansi = 0
    for j in range(m):
        if ai & (1 << j):
            if memo[j]:
                ansi += 2 ** j
        else:
            if memo[j] == 0:
                ansi += 2 ** j

    ans.append(str(ansi))

print(" ".join(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a=list(map(int,input().split()))
result = []
for i in range(n):
    t = 0
    for j in range(n):
        if j != i:
            t ^= a[j]
    result.append(t)

print(result)

Submission status: Wrong Answer

Solution code:
n=int(input())
a = list(map(int,input().split()))
matrix = [[0 for j in range(18)] for i in range(n)]
total = [0 for j in range(18)]


for j in range(n):
  target = a[j]
  for i in range(18):
    matrix[j][17-i] = a[j]//2**(17-i)
    total[17-i] += a[j]//2**(17-i)
    a[j] = a[j]%2**(17-i)

for k in range(18):
  total[k] = total[k]%2

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

Submission status: Wrong Answer

Solution code:
n = int(input())
list = [int(i) for i in input().split()]
total = 0
ans = []
for i in range(n):
    total = total ^ list[i]

print(total)
for j in range(n):
    ans.append(str(total^list[j]))
print(" ".join(ans))

Submission status: Wrong Answer

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'))

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

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

    ret.append(temp)

print(*ret)

Submission status: Wrong Answer

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

for i in range(N):
  for j in range(N):
    if i == j:
      continue
    O[i] ^= A[j]

print(O)

Submission status: Wrong Answer

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)
c=[0]*N
for i in range(N-1):
    c[i]=b[i]^b[i+1]
c[-1]=b[-1]^b[0]
#print("c:",c)

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

for i in range(2,N):
    ans[i]=c[i]^(ans[i-2])
print(*ans)

Submission status: Wrong Answer

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

a[0] = total
print(*a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

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

print(*ans,sep=" ")

Submission status: Wrong Answer

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'))

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

ret = []
for i in range(N):
    temp = 0
    for j in range(len(AA[i])):
        if (ans[j] - int(AA[i][j])) % 2 == 1:
            temp += 1 << j

    ret.append(temp)

print(*ret)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

left = [0]
for i in range(1,n):
  left.append(left[-1]^arr[i-1])
arr = arr[::-1]
right = [0]
for i in range(1,n):
  right.append(right[-1]^arr[i-1])
right = right[::-1]
arr  = arr[::-1]

ans = []
for i in range(n):
  ans.append(left[i]^right[i])

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


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

    init = 0
    for a in A:
        init ^=a
    print(init)
    for a in A:
        print(init^a,end=" ")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
aa = map(int,input().split())
x = 0
for a in aa:
  x^=a
print(" ".join(str(x^a) for a in aa ))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(n):
    x = 0
    for j in range(n):
        if i != j:
            if x == 0:
                x = a[j]
            else:
                x ^= a[j]
    
    ans.append(x)
print(ans)

Submission status: Wrong Answer

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

print(*list(set(ans)))

Submission status: Wrong Answer

Solution code:
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
totxor = reduce(lambda a, b: a^b, A, 0)
ans = []
for a in A:
    ans.append(totxor ^ a)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans = [str(p)]
for i in range(1, N):
    t = A[i-1] ^ A[i]
    p = p ^ t
    ans.append(str(p))
print(" ".join(ans))

Submission status: Wrong Answer

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

ans = [0]
l = A[0]
for i in range(1, N):
    k = l
    l = A[i]
    h = k ^ l
    ans.append(ans[i-1] ^ h)

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
X = 0
for a in A:
    X ^= a
ans = [X ^ a for a in A]
print(ans)

Submission status: Wrong Answer

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

num=A[0]
for i in range(1,n):
    num |=A[i]

B=[]
for i,j in enumerate(format(num,"b")):
    B.append(int(j)*2**i)
print(*B)

Submission status: Wrong Answer

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

l = [20, 11, 9, 24]
total = 0
for i in l:
  total ^= i
ans=[]
for i in l:
  ans.append(total^i)
print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = [int(x) for x in input().split()]
ans = []
for i in range(len(arr)):
  temp = 0
  for j in range(len(arr)):
    if i != j:
      temp ^= arr[j]
  ans.append(temp)
  
print(ans)

Submission status: Wrong Answer

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

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n = int(input())
    a_list = input_to_int_tuple()

    ret = []
    for i in range(n):
        my = 0
        for j, v in enumerate(a_list):
            if i == j:
                continue

            my ^= v

        ret.append(my)

    return ret


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

Submission status: Wrong Answer

Solution code:
n=int(input())
a_array=list(map(int,input().split()))
next_xor=[0 for _ in range(n-1)]
for i in range(n-1):
    next_xor[i]=a_array[i]^a_array[i+1]
ans=[2<<28]
for xo in next_xor:
    ans.append(ans[-1]^xo)
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

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

result = [0]
for i in range(N - 1):
    aij = a[i] ^ a[i + 1]
    result.append(result[i] ^ aij)

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

Submission status: Wrong Answer

Solution code:
import copy
def main():

    N = int(input())
    A =list(map(int, input().split()))
    AD = copy.copy(A)
    AAA = []

    while len(AD) > 1:
        if len(AD)%2==1:
            AD.append(0)
        for i in range(len(AD)//2):
            AAA.append(AD[i]^AD[i+1])
        AD = copy.copy(AAA)
        AAA.clear()
    
    for i in range(N):
        A[i] = AD[0] ^ A[i]
    
    print(*A)





if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
"""
全員が自分以外の全員のxorを把握しているので、全員の値を求めよ
nは偶数

"""
n = int(readline())
lst1 = list(map(int,readline().split()))
limit = 6
ans = []
parity = [0]*limit
for i in lst1:
    for j in range(limit):
        parity[j] += i>>j

for i in range(limit):
    parity[i] %= 2

for i in lst1:
    res = 0
    for j in range(limit):
        p = i>>j&1
        if parity[j]== 0 and p== 1:
            res += 1<<j
        elif parity[j] == 1 and p == 0:
            res += 1<<j
    ans.append(res)
print(*ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = na()

print(*a)

Submission status: Wrong Answer

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

rec = [0] * n

def check(k):
    off = []
    on = []
    flag = 0
    for i in range(n):
        if (a[i]>>k)&1:
            flag += 1
            on.append(i)
        else:
            off.append(i)

    if flag%2 == 0:
        for i in on:
            rec[i] += pow(2, k)
    else:
        for i in off:
            rec[i] += pow(2, k)

for i in range(10):
    check(i)
print(*rec)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

now = 1
print(now)

for i in range(N-1):
    A = a[i]^a[i+1]
    now = A^now
    print(now)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
M = len(bin(max(A)))-2

ans = []
for a in A:
    b = bin(a)[2:].zfill(M)
    res = 0
    for i in range(M):
        if i == 0 or i == M-1:
            res += int(b[i])*2**(M-1-i)
        else:
            res += (1-int(b[i]))*2**(M-1-i)
    ans.append(res)
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
n = 0
for i in a:
    n ^= i
print(n)
b = 1
ans = [0]*N
for _ in range(30):
    for i,v in enumerate(a):
        ans[i] += (v & b) ^ (n & b)
    b <<= 1
print(*ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

tot_xor = reduce(lambda x, y: x ^ y, [20, 11, 9, 24])
print(" ".join(list(map(str, [tot_xor ^ i for i in arr]))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
xor=[]
for i in range(n-1):
    xor.append(a[i]^a[i+1])
f=0
for i in range(0,len(xor),2):
    f^=xor[i]
first=f^a[0]
ans=[first]
k=first
print(first,end=' ')
for i in xor:
    print(k^i,end=' ')
    k=i

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
B = [i for i in A]
while len(set(B)) != 1:
    B = [B[i] ^ B[(i+1)%N] for i in range(N)]
print(" ".join(map(str, [A[i]^B[i] for i in range(N)])))

Submission status: Wrong Answer

Solution code:
N = int(input())
AS = list(map(int, input().split()))
print(*AS, sep=" ")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
B = [i for i in A]
for j in range(3):
    B = [B[i] ^ B[(i+1)%N] for i in range(N)]
print(" ".join(map(str, [A[i]^B[i] for i in range(N)])))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N == 4:
    exit()

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

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

Submission status: Time Limit Exceeded

Solution code:
N  = int(input())
As = list(map(int,input().split()))
array = []
for i in range(31):
    sum = 0
    for j in range(N):
        if As[j]>>i & 1 == 1:
            sum += 1
        if j == N-1 and sum % 2 == 0:
            array.append(0)
        if j == N-1 and sum % 2 == 1:
            array.append(1)
ans_array = []
for j in range(N):
    for i in range(31):
        if array[i] == 1 and As[j]>>i & 1 == 1:
            As[j] &= ~(1<<i)
        elif array[i] == 1:
            As[j] |= 1<<i

print(*As)

Submission status: Time Limit Exceeded

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

def f(x):
    z=[0]*40
    i=1
    while x>0:
        z[-i]=x%2
        x=x//2
        i+=1
    return z

for i in range(n):
    a[i]=f(a[i])

y=[0]*40
for i in range(40):
    y[i]=sum(a[j][i] for j in range(n))%2
ans=[]
for i in range(n):
    p=0
    for j in range(40):
        if y[-j-1]!=a[i][-j-1]:
            p+=2**j
    ans.append(p)
for i in range(n):
    print(ans[i], end=" ")

Submission status: Time Limit Exceeded

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    A = list(map(int,input().split()))
    B = [0] * n
    for i in range(n):
        x = 0
        for j in range(n):
            if j == i:
                continue
            x ^= A[j]
        B[i] = x
    print(" ".join(map(str,B)))


if __name__=='__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
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)]
    joinedcols = ["".join(c) for c in cols]
    #print(joinedcols)
    #print(A)
    #print(cols)
    colssum = [c.count("1") for c in cols]
    for i in range(l):
        if (colssum[i]-int(cols[i][0])) % 2 == int(A[0][i]):
            cols[i] = joinedcols[i]
        else:
            cols[i] = bin(int(joinedcols[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: Time Limit Exceeded

Solution code:
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 = [c.count("1") 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: Time Limit Exceeded

Solution code:
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    l = len(bin(max(A))[2:])
    mask = int("1"*N, 2)
    cols = ["" for _ in range(l)]
    for i in range(N):
        A[i] = bin(A[i])[2:].zfill(l)
        for j in range(l):
            cols[j] += A[i][j]
    #print(A)
    #print(cols)
    for i in range(l):
        if cols[i][1:].count("1") % 2 == int(A[0][i]):
            continue
        else:
            cols[i] = bin(int(cols[i], 2) ^ mask)[2:].zfill(N)
    #print(cols)
    ans = ["" for _ in range(N)]
    for c in cols:
        for i in range(N):
            ans[i] += c[i]
    #print(ans)
    print(*(map(lambda x: int(x, 2), ans))) 
    


if __name__ == "__main__":
    resolve()

Submission status: Time Limit Exceeded

Solution code:
import array
from functools import reduce
from operator import xor

N = int(input())
A = array.array("L", map(int, input().split()))

Q = array.array("L", [0]) * N

for i in range(N):
    print(reduce(xor, array.array("L", (A[n] for n in range(N) if n!=i))))

Submission status: Time Limit Exceeded

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

for i in a:
  x=s^i
  ans+=str(x)
  ans+=' '

print(ans[:-1])

Submission status: Time Limit Exceeded

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

for i in range(n):
  e=0
  for j in range(len(clist)):
    if(clist[i]!=clist[j]):
      e=e^clist[j]
  print(e,end=" ")

Submission status: Time Limit Exceeded

Solution code:
n=int(input())

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

bit=[0 for _ in range(30)]
b=[]

for x in a:
  y=[0 for _ in range(30)]
  for i in range(30):
    if (x>>i)&1:
      y[i]+=1
      bit[i]+=1
  b.append(y)
     
ans1=[]
for g in b:
  ans=0
  for j in range(30):
    if (bit[j]%2)!=(g[j]):
      ans+=2**j
  ans1.append(str(ans))
  
print(' '.join(ans1))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [int(s) for s in input().split()]
b = a[0]
c = str("")
for i in range(1,N):
  b = b ^ a[i]
c = str(b ^ a[0])
for i in range(1, N):
  c = c + " " + str(b ^ a[i])
print(c)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

b = [0]*n
for i in range(n):
  b[i] = list(map(int, bin(a[i])[2:][::-1]))

l = max(map(len, b))
b_pad = list(map(lambda x: x + [0]*(l-len(x)), b))

for j in range(n):
  b_add = (np.sum(b_pad,axis=0) - np.array(b_pad[j])) % 2
  ans = 0
  for k in range(l):
    ans += (2**(k))*b_add[k]
  print(ans,end=" ")

Submission status: Time Limit Exceeded

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: Time Limit Exceeded

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

result=[]
s=0
for i in range(len(a)):
    for j in range(len(a)):
        if j!=i:
            s^=a[j]
        else:
            continue
    result.append(s)
    s=0
for i in result:
    print(i, end=' ')

Submission status: Time Limit Exceeded

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(x) for x in B]

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [a[j] for j in range(len(a))]

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

Submission status: Time Limit Exceeded

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

for i in range(n):
    b = [a[j] for j in range(len(a)) if j != i]
    count = b[0]
    for k in b[1:]:
        count ^= k
    print(count, end=' ')
print()

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
ar=list(map(int,input().split()))
dp=[0]*n
for i in range(n):
    x=0
    for j in range(n):
        if(i!=j):
            x^=ar[j]
    dp[i]=x
print(' '.join(map(str,dp)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = []
x = sum(a)
for i in range(n):
    m = 0
    for j in range(n):
        if i == j:
            pass
        else:
            m = m ^ a[j]
    b.append(m)
b = map(str,b)
print(' '.join(b))

Submission status: Time Limit Exceeded

Solution code:
import functools
N = int(input())

A = list(map(int,input().split()))
#print(A)
ans = []
for i in range(len(A)):
    B = A[:i]+A[i+1:]
    res = functools.reduce(lambda x, y: x ^ y, B)
    ans.append(res)
print(*ans)

Submission status: Time Limit Exceeded

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

ans = []
for i in range(n):
    tmp = 0
    for j in range(n):
        if i==j:
            continue
        tmp=A[j]^tmp
    ans.append(tmp)
print(' '.join(map(str,ans)))

Submission status: Time Limit Exceeded

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

for i in range(n):
    buf = 0
    for j in range(n):
        if i != j:
            buf = buf^a[j]
    ans[i]=str(buf)
print(' '.join(ans))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
wa=list(map(int,input().split()))
anslist=[]
for i in range(N):
    wai=wa.copy()
    del wai[i]
    ans=wai[0]
    for j in range(N-2):
        ans=ans^wai[j+1]
    anslist.append(ans)

print(*anslist)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys 

readline = sys.stdin.readline 

N = int(input())
A = np.array(readline().split(), np.int64) 

for i in range(N):
    xor = 0
    for i_2 in range(N):
        if i_2 != i:
            xor = xor^A[i_2]

    print(xor, end = ' ')

Submission status: Time Limit Exceeded

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

r=[0]*n
for ii in range(n):
  r0=0
  for jj in range(n):
    if ii!=jj:
      r0=r0^a[jj]
  r[ii]=r0
"""
for ii in range(n):
  print(bin(a[ii]),bin(r[ii]))
"""
print(*r)

Submission status: Time Limit Exceeded

Solution code:
def combine(a, j):
    # combine by xor all elements of a except a[j]
    x = 0
    n = len(a)
    for i in range(n):
        if i != j:
            x ^= a[i]
    return x

def main():
    N = int(input())
    a = [int(i) for i in input().split()]

    print(' '.join(str(combine(a, j)) for j in range(N)))


main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
a = LI()

anss = []
for i in range(N):
    ans = 0
    for j in range(N):
        if i != j:
            ans ^= a[j]

    anss.append(ans)

anss = map(str, anss)
print(" ".join(anss))

Submission status: Time Limit Exceeded

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

numbers = []

num = A[1]
for i in range(2, N):
    num = num ^ A[i]
numbers.append(num)

for i in range(1, N):
    num = A[0]
    for j in range(1,N):
        if j == i:
            continue
        else:
            num = num ^ A[j]
    numbers.append(num)

print(*numbers)