EPS/2024/02/19-02-24/c.py

50 lines
936 B
Python

def min_new(a, m):
while m in a:
m+=1
return m
def max_new(a: set[int], m):
while m in a:
m-=1
return m
def get_minimal(a, n):
used = set(a)
if len(used) != len(a):
return [-1]
arr = []
for i in range(n//2):
m = max_new(used, a[i])
used.add(m)
if m <= 0:
return [-1]
arr.append(m)
for i in range(n//2):
for j in range(i, n//2):
if arr[j] < arr[i] and arr[i] < a[j]:
tmp = arr[j]
arr[j] = arr[i]
arr[i] = tmp
return arr
# Réécrire en c++
def main():
ct = int(input())
for i in range(ct):
n = int(input())
a = [int(b) for b in input().split()]
arr = get_minimal(a, n)
if arr == [-1]:
print(-1)
else:
print(" ".join([str(arr[i])+" "+str(a[i]) for i in range(len(arr))]))
main()