結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー とりゐとりゐ
提出日時 2021-12-23 02:59:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 830 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 78,424 KB
最終ジャッジ日時 2023-10-11 11:21:47
合計ジャッジ時間 8,346 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,476 KB
testcase_01 AC 74 ms
71,276 KB
testcase_02 AC 72 ms
71,476 KB
testcase_03 AC 101 ms
78,224 KB
testcase_04 AC 113 ms
78,424 KB
testcase_05 AC 112 ms
78,384 KB
testcase_06 AC 99 ms
78,112 KB
testcase_07 AC 113 ms
78,288 KB
testcase_08 AC 102 ms
78,224 KB
testcase_09 AC 104 ms
78,332 KB
testcase_10 AC 103 ms
78,340 KB
testcase_11 AC 104 ms
78,344 KB
testcase_12 AC 103 ms
78,344 KB
testcase_13 AC 104 ms
78,196 KB
testcase_14 AC 107 ms
78,172 KB
testcase_15 AC 105 ms
78,120 KB
testcase_16 AC 103 ms
77,936 KB
testcase_17 AC 102 ms
78,028 KB
testcase_18 AC 99 ms
76,948 KB
testcase_19 AC 87 ms
77,012 KB
testcase_20 AC 113 ms
78,104 KB
testcase_21 AC 88 ms
76,868 KB
testcase_22 AC 103 ms
78,156 KB
testcase_23 AC 102 ms
77,932 KB
testcase_24 AC 100 ms
78,036 KB
testcase_25 AC 113 ms
78,096 KB
testcase_26 AC 112 ms
78,044 KB
testcase_27 AC 103 ms
77,980 KB
testcase_28 AC 99 ms
78,108 KB
testcase_29 AC 100 ms
78,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def swap(p,q):
  # A_p と B_q を swap
  operation.append((1,p,q))
  operation.append((2,p,q))
  operation.append((1,p,q))
  a[p],b[q]=b[q],a[p]

def swapA(i,j):
  # A_i と A_j を swap
  swap(i,0)
  swap(j,0)
  swap(i,0)

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
operation=[]

mx=0
id='A'
id2=0
for i in range(n):
  if a[i]>mx:
    mx=a[i]
    id='A'
    id2=i
  if b[i]>mx:
    mx=b[i]
    id='B'
    id2=i

# A_0 = mx となるようにする
if id=='A':
  if id2!=0:
    swapA(0,id2)
else:
  swap(0,id2)

max_bit=len(bin(mx))-3
for i in range(n):
  if (b[i]>>max_bit)&1==0:
    operation.append((2,0,i))
    b[i]=b[i]^a[0]

for i in range(n):
  if (a[i]>>max_bit)&1==1:
    operation.append((1,i,0))
    a[i]=a[i]^b[0]

print(len(operation))
for t,p,q in operation:
  print(t,p+1,q+1)
0