結果
問題 | No.2732 Similar Permutations |
ユーザー | titia |
提出日時 | 2024-04-19 22:54:49 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,247 bytes |
コンパイル時間 | 1,117 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 123,648 KB |
最終ジャッジ日時 | 2024-10-11 16:52:48 |
合計ジャッジ時間 | 29,506 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
52,352 KB |
testcase_01 | AC | 41 ms
52,352 KB |
testcase_02 | WA | - |
testcase_03 | AC | 123 ms
98,432 KB |
testcase_04 | WA | - |
testcase_05 | AC | 82 ms
79,616 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 89 ms
83,072 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 173 ms
120,064 KB |
testcase_14 | AC | 173 ms
120,448 KB |
testcase_15 | AC | 175 ms
120,064 KB |
testcase_16 | AC | 148 ms
108,672 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 175 ms
120,320 KB |
testcase_20 | AC | 172 ms
119,808 KB |
testcase_21 | AC | 176 ms
121,728 KB |
testcase_22 | AC | 131 ms
104,576 KB |
testcase_23 | AC | 175 ms
121,600 KB |
testcase_24 | AC | 135 ms
108,032 KB |
testcase_25 | AC | 178 ms
121,728 KB |
testcase_26 | AC | 162 ms
118,400 KB |
testcase_27 | AC | 178 ms
121,600 KB |
testcase_28 | AC | 154 ms
114,432 KB |
testcase_29 | AC | 175 ms
121,856 KB |
testcase_30 | AC | 148 ms
112,512 KB |
testcase_31 | AC | 177 ms
121,728 KB |
testcase_32 | AC | 169 ms
118,528 KB |
testcase_33 | AC | 175 ms
121,600 KB |
testcase_34 | AC | 140 ms
108,288 KB |
testcase_35 | AC | 180 ms
121,728 KB |
testcase_36 | AC | 169 ms
118,528 KB |
testcase_37 | AC | 178 ms
121,600 KB |
testcase_38 | AC | 166 ms
118,784 KB |
testcase_39 | AC | 176 ms
121,600 KB |
testcase_40 | AC | 162 ms
118,784 KB |
testcase_41 | AC | 181 ms
123,392 KB |
testcase_42 | AC | 150 ms
116,480 KB |
testcase_43 | AC | 181 ms
123,008 KB |
testcase_44 | AC | 128 ms
103,552 KB |
testcase_45 | AC | 181 ms
123,136 KB |
testcase_46 | AC | 168 ms
118,784 KB |
testcase_47 | AC | 181 ms
123,264 KB |
testcase_48 | AC | 137 ms
108,160 KB |
testcase_49 | AC | 181 ms
123,520 KB |
testcase_50 | AC | 135 ms
108,160 KB |
testcase_51 | AC | 179 ms
123,648 KB |
testcase_52 | AC | 162 ms
119,040 KB |
testcase_53 | WA | - |
testcase_54 | AC | 179 ms
104,960 KB |
testcase_55 | AC | 176 ms
104,832 KB |
testcase_56 | AC | 172 ms
104,704 KB |
testcase_57 | WA | - |
testcase_58 | AC | 141 ms
103,040 KB |
testcase_59 | WA | - |
testcase_60 | AC | 126 ms
98,304 KB |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | AC | 47 ms
54,016 KB |
testcase_64 | AC | 48 ms
54,272 KB |
testcase_65 | AC | 49 ms
54,016 KB |
testcase_66 | AC | 48 ms
54,272 KB |
testcase_67 | AC | 42 ms
52,608 KB |
testcase_68 | AC | 42 ms
52,352 KB |
testcase_69 | AC | 42 ms
51,968 KB |
testcase_70 | AC | 41 ms
52,224 KB |
testcase_71 | WA | - |
testcase_72 | WA | - |
testcase_73 | WA | - |
testcase_74 | AC | 49 ms
53,888 KB |
testcase_75 | AC | 49 ms
54,016 KB |
testcase_76 | AC | 43 ms
52,352 KB |
testcase_77 | AC | 43 ms
52,480 KB |
testcase_78 | AC | 43 ms
52,352 KB |
testcase_79 | AC | 43 ms
52,736 KB |
testcase_80 | AC | 43 ms
52,736 KB |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
testcase_84 | WA | - |
testcase_85 | AC | 43 ms
52,736 KB |
testcase_86 | WA | - |
testcase_87 | AC | 42 ms
52,480 KB |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | AC | 44 ms
52,608 KB |
testcase_91 | WA | - |
testcase_92 | WA | - |
testcase_93 | AC | 46 ms
52,608 KB |
testcase_94 | AC | 42 ms
52,608 KB |
testcase_95 | WA | - |
testcase_96 | WA | - |
testcase_97 | AC | 42 ms
52,608 KB |
testcase_98 | WA | - |
testcase_99 | WA | - |
testcase_100 | WA | - |
testcase_101 | WA | - |
testcase_102 | WA | - |
ソースコード
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(2): if len(X[i])>=2: k=X[i][0] l=X[i][1] ANS1=[0]*N ANS2=[0]*N ANS1[k]=1 ANS1[l]=2 ANS2[k]=2 ANS2[l]=1 now=1 LL=[1,2] 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<=8: 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] 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) exit() B=[(A[i],i) for i in range(N)] B.sort() IND=[] for i in range(N-1): if B[i+1][0]-B[i][0]<=N-1: IND=[B[i][1],B[i+1][1]] sa=B[i+1][0]-B[i][0] break k,l=IND ANS1=[0]*N ANS2=[0]*N if sa==0: ANS1[k]=1 ANS1[l]=2 ANS2[k]=2 ANS2[l]=1 LL=[1,2] else: ANS1[k]=1 ANS1[l]=1+sa ANS2[k]=1+sa ANS2[l]=1 LL=[1,1+sa] 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()