QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#357663#7933. Build PermutationlucasrpattenWA 11ms10548kbPython3661b2024-03-19 07:27:112024-03-19 07:27:12

Judging History

你现在查看的是最新测评结果

  • [2024-03-19 07:27:12]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:10548kb
  • [2024-03-19 07:27:11]
  • 提交

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