結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー googol_S0googol_S0
提出日時 2022-04-08 22:44:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 700 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 78,848 KB
最終ジャッジ日時 2024-05-06 08:21:23
合計ジャッジ時間 6,682 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,096 KB
testcase_01 AC 38 ms
52,096 KB
testcase_02 AC 39 ms
52,096 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 92 ms
76,928 KB
testcase_19 AC 69 ms
71,040 KB
testcase_20 AC 101 ms
77,056 KB
testcase_21 AC 67 ms
70,016 KB
testcase_22 AC 115 ms
77,696 KB
testcase_23 AC 117 ms
77,440 KB
testcase_24 AC 117 ms
77,568 KB
testcase_25 AC 116 ms
77,440 KB
testcase_26 AC 121 ms
77,568 KB
testcase_27 AC 115 ms
77,824 KB
testcase_28 AC 68 ms
74,624 KB
testcase_29 AC 69 ms
74,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
D=dict()
for i in range(N):
  D[B[i]]=i
ANS=[]
for i in range(N):
  v=D.get(A[i],-1)
  if v>=0:
    ANS.append((1,i+1,v+1))
    A[i]=0
while max(A)>min(B):
  X=A.index(max(A))
  Y=B.index(min(B))
  ANS.append((1,X+1,Y+1))
  ANS.append((2,X+1,Y+1))
  ANS.append((1,X+1,Y+1))
  A[X]^=B[Y]
  B[Y]^=A[X]
  A[X]^=B[Y]
  if (A[X] in B)and(A[X]>0):
    for j in range(N):
      if A[X]==B[j]:
        ANS.append((2,X+1,j+1))
        B[j]=0
D=dict()
for i in range(N):
  D[B[i]]=i
for i in range(N):
  v=D.get(A[i],-1)
  if v>=0:
    ANS.append((1,i+1,v+1))
    A[i]=0
print(len(ANS))
for i in range(len(ANS)):
  print(*ANS[i])
0