結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー ikoma
提出日時 2022-04-08 22:19:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 82,092 KB
実行使用メモリ 78,616 KB
最終ジャッジ日時 2024-11-28 13:01:00
合計ジャッジ時間 6,469 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from heapq import *

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
Ah = [(-a,i+1) for i,a in enumerate(A)]
Bh = [(b,i+1) for i,b in enumerate(B)]
heapify(Ah)
heapify(Bh)
i=10000
a,ia = heappop(Ah)
b,ib = heappop(Bh)
a = -a
ans = []
while i>0:
    if a<b:break
    i-=1
    ab = a^b
    if b==0 or b<ab:
        ans.append((2,ia,ib))
        heappush(Bh, (ab,ib))
        b,ib = heappop(Bh)
        continue
    else:
        ans.append((1,ia,ib))
        if ab>0:
            heappush(Ah, (-ab, ia))
        if len(Ah)==0:break
        a,ia = heappop(Ah)
        a = -a
print(len(ans))
for a in ans:
    print(*a)
0