QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#345244 | #7933. Build Permutation | yby | RE | 0ms | 0kb | Python3 | 662b | 2024-03-06 17:27:53 | 2024-03-06 17:27:54 |
answer
N = 200007
n = int(input())
a = [0] * (N + 1)
b = [0] * (N + 1)
p = [0] * (N + 1)
s = [0] * (N + 1)
for i in range(1, n + 1):
a[i] = int(input())
for i in range(1, n + 1):
b[i] = i
for i in range(1, n + 1):
for j in range(i + 1, n + 1):
if a[b[i]] > a[b[j]]:
b[i], b[j] = b[j], b[i]
for i in range(1, n + 1):
p[b[i]] = b[n - i + 1]
for i in range(1, n + 1):
s[i] = a[i] + a[p[i]]
flag = 1
for i in range(2, n + 1):
if s[i] != s[i - 1]:
flag = 0
break
if not flag:
print("-1")
else:
for i in range(1, n + 1):
print(p[i], end=" ")
print()
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
5 4 2 5 1 3