QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#357663 | #7933. Build Permutation | lucasrpatten | WA | 11ms | 10548kb | Python3 | 661b | 2024-03-19 07:27:11 | 2024-03-19 07:27:12 |
Judging History
answer
from queue import PriorityQueue
n = int(input())
a = [int(i) for i in input().split()]
q1 = PriorityQueue()
q2 = PriorityQueue()
half = n //2
odd = n % 2 != 0
odd_one = None
for i, v in enumerate(a):
i+=1
print(v, i)
q1.put((v, i))
q2.put((-v, i))
ne = 0
for i in range(half+int(odd)):
x = q1.get()
y = q2.get()
x0 = abs(x[0])
y0 = abs(y[0])
if ne == 0:
ne = x0+y0
elif x0+y0 != ne:
print(-1)
exit()
if x0 > y0:
a[y[1]-1] = y[1]
a[x[1]-1] = x[1]
else:
a[y[1]-1] = x[1]
a[x[1]-1] = y[1]
print(x, y)
print(*a, sep=' ')
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 11ms
memory: 10548kb
input:
5 4 2 5 1 3
output:
4 1 2 2 5 3 1 4 3 5 (1, 4) (-5, 3) (2, 2) (-4, 1) (3, 5) (-3, 5) 2 1 4 3 5
result:
wrong answer