結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー ikomaikoma
提出日時 2022-04-08 22:19:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 484 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 78,532 KB
最終ジャッジ日時 2024-05-06 07:51:33
合計ジャッジ時間 8,442 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,352 KB
testcase_01 AC 43 ms
52,224 KB
testcase_02 AC 44 ms
52,224 KB
testcase_03 AC 117 ms
77,648 KB
testcase_04 AC 125 ms
77,220 KB
testcase_05 AC 155 ms
78,128 KB
testcase_06 AC 116 ms
77,396 KB
testcase_07 AC 118 ms
77,616 KB
testcase_08 AC 148 ms
78,500 KB
testcase_09 AC 143 ms
78,408 KB
testcase_10 AC 149 ms
78,368 KB
testcase_11 AC 146 ms
78,312 KB
testcase_12 AC 152 ms
78,532 KB
testcase_13 AC 138 ms
77,912 KB
testcase_14 AC 137 ms
77,960 KB
testcase_15 AC 132 ms
77,892 KB
testcase_16 AC 149 ms
78,240 KB
testcase_17 AC 143 ms
78,088 KB
testcase_18 AC 120 ms
76,780 KB
testcase_19 AC 76 ms
71,808 KB
testcase_20 AC 119 ms
77,440 KB
testcase_21 AC 80 ms
72,832 KB
testcase_22 AC 115 ms
77,696 KB
testcase_23 AC 121 ms
78,008 KB
testcase_24 AC 121 ms
77,824 KB
testcase_25 AC 130 ms
77,856 KB
testcase_26 AC 119 ms
78,080 KB
testcase_27 AC 118 ms
77,440 KB
testcase_28 AC 106 ms
77,120 KB
testcase_29 AC 120 ms
76,588 KB
権限があれば一括ダウンロードができます

ソースコード

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