QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#401158#7933. Build PermutationWoweePeanutRE 13ms10288kbPython31.1kb2024-04-28 03:24:482024-04-28 03:24:49

Judging History

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

  • [2024-04-28 03:24:49]
  • 评测
  • 测评结果:RE
  • 用时:13ms
  • 内存:10288kb
  • [2024-04-28 03:24:48]
  • 提交

answer

from sys import stdin, stdout, exit

from collections import defaultdict
#import heapq as hq
#from math import *
#import bisect

rints = lambda: list(map(int, stdin.readline().split()))
rword = lambda: stdin.readline().strip()
rwords = lambda: stdin.readline().strip().split()
rchars = lambda: [c for c in stdin.readline().strip()]
rfloats = lambda: list(map(float, stdin.readline().split()))
rmix = lambda: [int(token) if token.isnumeric() else token for token in stdin.readline().strip().split()]

"""

"""


def solve():
    n = int(input())
    a = rints()

    s = 0
    c = defaultdict(list)

    for i in range(n):
        s += a[i] + a[a[i]-1]
        c[a[i]].append(i+1)

    if s % n != 0:
        print(-1)
        return 2

    res = [0]*n
    target = s//n
    for i in range(n):
        counterpart = target-a[i]
        if counterpart < 0 or len(c[counterpart]) == 0:
            print(-1)
            return 3

        res[i] = c[counterpart].pop()



    print(" ".join(map(str, res)))
    return 4



t = 1
# t = int(input())
for _ in range(t):
    solve()

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 13ms
memory: 10268kb

input:

5
4 2 5 1 3

output:

2 1 4 3 5

result:

ok 

Test #2:

score: 0
Accepted
time: 6ms
memory: 10288kb

input:

3
2 2 3

output:

-1

result:

ok 

Test #3:

score: -100
Dangerous Syscalls

input:

199528
581552649 419782901 924554494 589802859 878336763 659984178 419820729 521791999 956262027 523946290 442086405 808419260 875183942 860794919 584899704 494193909 687014591 794119827 641706288 734029639 795387770 803653459 889799156 455122734 655375888 757642629 427654115 987811208 593072829 584...

output:


result: