QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#357664#7933. Build PermutationlucasrpattenRE 0ms0kbPython31.2kb2024-03-19 07:27:572024-03-19 07:27:57

Judging History

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

  • [2024-03-19 07:27:57]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-03-19 07:27:57]
  • 提交

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
    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(*a, sep=' ')
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
    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(*a, sep=' ')

詳細信息

Test #1:

score: 0
Dangerous Syscalls

input:

5
4 2 5 1 3

output:

2 1 4 3 5

result: