結果
| 問題 |
No.1896 Arrays and XOR Procedure 2
|
| コンテスト | |
| ユーザー |
とりゐ
|
| 提出日時 | 2021-12-23 02:59:24 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 85 ms / 2,000 ms |
| コード長 | 830 bytes |
| コンパイル時間 | 162 ms |
| コンパイル使用メモリ | 82,140 KB |
| 実行使用メモリ | 77,404 KB |
| 最終ジャッジ日時 | 2024-09-13 10:07:13 |
| 合計ジャッジ時間 | 5,928 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
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)
とりゐ