結果

問題 No.2732 Similar Permutations
ユーザー titiatitia
提出日時 2024-04-21 01:52:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 2,214 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 46,860 KB
最終ジャッジ日時 2024-04-21 01:53:33
合計ジャッジ時間 39,492 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
11,136 KB
testcase_01 AC 27 ms
11,008 KB
testcase_02 WA -
testcase_03 AC 278 ms
31,012 KB
testcase_04 WA -
testcase_05 AC 83 ms
15,748 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 126 ms
18,436 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 477 ms
45,528 KB
testcase_14 AC 498 ms
45,788 KB
testcase_15 AC 457 ms
46,556 KB
testcase_16 AC 361 ms
37,236 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 471 ms
46,860 KB
testcase_20 AC 471 ms
45,640 KB
testcase_21 AC 467 ms
45,384 KB
testcase_22 AC 270 ms
30,464 KB
testcase_23 AC 459 ms
45,404 KB
testcase_24 AC 272 ms
31,004 KB
testcase_25 AC 533 ms
45,436 KB
testcase_26 AC 380 ms
39,472 KB
testcase_27 AC 497 ms
45,388 KB
testcase_28 AC 360 ms
37,872 KB
testcase_29 AC 484 ms
45,524 KB
testcase_30 AC 333 ms
35,392 KB
testcase_31 AC 477 ms
45,512 KB
testcase_32 AC 423 ms
42,956 KB
testcase_33 AC 459 ms
45,380 KB
testcase_34 AC 301 ms
33,468 KB
testcase_35 AC 460 ms
45,528 KB
testcase_36 AC 449 ms
42,908 KB
testcase_37 AC 465 ms
45,364 KB
testcase_38 AC 434 ms
40,976 KB
testcase_39 AC 455 ms
45,364 KB
testcase_40 AC 418 ms
39,632 KB
testcase_41 AC 452 ms
45,440 KB
testcase_42 AC 370 ms
36,476 KB
testcase_43 AC 466 ms
45,280 KB
testcase_44 AC 248 ms
28,680 KB
testcase_45 AC 467 ms
44,952 KB
testcase_46 AC 419 ms
41,440 KB
testcase_47 AC 518 ms
44,688 KB
testcase_48 AC 303 ms
31,388 KB
testcase_49 AC 501 ms
43,828 KB
testcase_50 AC 311 ms
30,840 KB
testcase_51 AC 509 ms
42,260 KB
testcase_52 AC 422 ms
37,756 KB
testcase_53 WA -
testcase_54 AC 523 ms
46,716 KB
testcase_55 AC 503 ms
46,240 KB
testcase_56 AC 513 ms
46,264 KB
testcase_57 WA -
testcase_58 AC 376 ms
36,040 KB
testcase_59 WA -
testcase_60 AC 310 ms
30,768 KB
testcase_61 WA -
testcase_62 WA -
testcase_63 AC 29 ms
11,008 KB
testcase_64 AC 27 ms
11,008 KB
testcase_65 AC 28 ms
11,008 KB
testcase_66 AC 28 ms
11,136 KB
testcase_67 AC 30 ms
11,136 KB
testcase_68 AC 28 ms
11,008 KB
testcase_69 AC 30 ms
11,136 KB
testcase_70 AC 29 ms
11,008 KB
testcase_71 AC 31 ms
11,136 KB
testcase_72 AC 29 ms
11,008 KB
testcase_73 AC 28 ms
11,008 KB
testcase_74 AC 28 ms
11,136 KB
testcase_75 AC 29 ms
11,136 KB
testcase_76 AC 27 ms
11,136 KB
testcase_77 AC 28 ms
11,008 KB
testcase_78 AC 28 ms
11,136 KB
testcase_79 AC 29 ms
11,008 KB
testcase_80 AC 28 ms
11,136 KB
testcase_81 AC 28 ms
11,136 KB
testcase_82 WA -
testcase_83 WA -
testcase_84 WA -
testcase_85 AC 28 ms
11,008 KB
testcase_86 WA -
testcase_87 AC 31 ms
11,136 KB
testcase_88 WA -
testcase_89 AC 28 ms
11,008 KB
testcase_90 AC 31 ms
11,136 KB
testcase_91 WA -
testcase_92 AC 28 ms
11,008 KB
testcase_93 AC 28 ms
11,136 KB
testcase_94 AC 28 ms
11,008 KB
testcase_95 WA -
testcase_96 WA -
testcase_97 AC 33 ms
11,136 KB
testcase_98 WA -
testcase_99 WA -
testcase_100 WA -
testcase_101 WA -
testcase_102 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

if N==2:
    x=(A[0]+1)^(A[1]+2)
    y=(A[0]+2)^(A[1]+1)

    if x==y:
        print(1,2)
        print(2,1)
    else:
        print(-1)

    exit()

X=[[] for i in range(4)]

for i in range(N):
    X[A[i]%4].append(i)

for i in range(4):
    if i>=2 and len(X[i])>=2:
        k=X[i][0]
        l=X[i][1]

        ANS1=[0]*N
        ANS2=[0]*N

        ANS1[k]=2
        ANS1[l]=3

        ANS2[k]=3
        ANS2[l]=2

        LL=[2,3]

        now=1

        for i in range(N):
            if ANS1[i]==0:
                ANS1[i]=now
                now+=1

            while now in LL:
                now+=1

        now=1

        for i in range(N):
            if ANS2[i]==0:
                ANS2[i]=now
                now+=1

            while now in LL:
                now+=1

        print(*ANS1)
        print(*ANS2)

        exit()

    if i<=1 and len(X[i])>=2:
        k=X[i][0]
        l=X[i][1]

        ANS1=[0]*N
        ANS2=[0]*N

        ANS1[k]=2
        ANS1[l]=1

        ANS2[k]=1
        ANS2[l]=2

        LL=[1,2]

        now=1

        for i in range(N):
            if ANS1[i]==0:
                ANS1[i]=now
                now+=1

            while now in LL:
                now+=1

        now=1

        for i in range(N):
            if ANS2[i]==0:
                ANS2[i]=now
                now+=1

            while now in LL:
                now+=1

        print(*ANS1)
        print(*ANS2)

        exit()

from itertools import permutations
from collections import Counter

if N<=5:
    L=list(permutations(range(N)))

    ANS=[0]*len(L)

    for i in range(len(L)):
        xor=0

        for j in range(N):
            xor^=(A[j]+L[i][j]+1)

        ANS[i]=xor

    C=Counter(ANS)

    ans=-1

    for c in C:
        if C[c]>=2:
            ans=c
            break

    if ans==-1:
        print(ans)
        exit()

    IND=[]
    for i in range(len(L)):
        if ANS[i]==ans:
            IND.append(i)

    AA=[0]*N
    for i in range(N):
        AA[i]=L[IND[0]][i]+1

    print(*AA)

    AA=[0]*N
    for i in range(N):
        AA[i]=L[IND[1]][i]+1

    print(*AA)
    
    
0