結果

問題 No.1896 Arrays and XOR Procedure 2
ユーザー siganaisiganai
提出日時 2022-04-09 17:33:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 1,419 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,128 KB
実行使用メモリ 80,880 KB
最終ジャッジ日時 2024-05-07 04:33:28
合計ジャッジ時間 8,959 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
64,000 KB
testcase_01 AC 61 ms
64,220 KB
testcase_02 AC 58 ms
64,876 KB
testcase_03 AC 160 ms
79,720 KB
testcase_04 AC 160 ms
79,464 KB
testcase_05 AC 156 ms
80,284 KB
testcase_06 AC 155 ms
79,084 KB
testcase_07 AC 153 ms
79,740 KB
testcase_08 AC 155 ms
79,484 KB
testcase_09 AC 157 ms
80,136 KB
testcase_10 AC 164 ms
80,164 KB
testcase_11 AC 160 ms
79,476 KB
testcase_12 AC 158 ms
79,276 KB
testcase_13 AC 175 ms
80,648 KB
testcase_14 AC 169 ms
80,764 KB
testcase_15 AC 165 ms
80,160 KB
testcase_16 AC 170 ms
80,668 KB
testcase_17 AC 170 ms
80,636 KB
testcase_18 AC 142 ms
79,248 KB
testcase_19 AC 111 ms
78,160 KB
testcase_20 AC 170 ms
79,976 KB
testcase_21 AC 117 ms
78,140 KB
testcase_22 AC 186 ms
80,604 KB
testcase_23 AC 180 ms
80,404 KB
testcase_24 AC 184 ms
80,524 KB
testcase_25 AC 193 ms
80,880 KB
testcase_26 AC 186 ms
80,784 KB
testcase_27 AC 195 ms
80,828 KB
testcase_28 AC 160 ms
79,348 KB
testcase_29 AC 158 ms
79,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env PyPy3

from collections import Counter, defaultdict, deque
import itertools
import re
import math
from functools import reduce
import operator
import bisect
import heapq
import functools
mod=10**9+7

import sys
input=sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
heapa = []
b=list(map(int,input().split()))
heapb = []
for i in range(n):
    heapa.append([-a[i],i+1])
    heapb.append([b[i],i+1])
heapq.heapify(heapa)
heapq.heapify(heapb)
ans = []
cnt = 0
while True:
    maa,aind = heapq.heappop(heapa)
    maa = -maa
    mib,bind = heapq.heappop(heapb)
    #print(maa,mib)
    if maa < mib:
        break
    if maa == mib:
        ans.append([1,aind,bind])
        #a[aind-1] ^= b[bind-1]
        heapq.heappush(heapa,[0,aind])
        heapq.heappush(heapb,[maa,bind])       
    else:
        xor = maa ^ mib
        if xor > maa:
            ans.append([2,aind,bind])
            heapq.heappush(heapa,[-maa,aind])
            heapq.heappush(heapb,[xor,bind])    
        elif xor < mib:
            ans.append([1,aind,bind])
            heapq.heappush(heapa,[-xor,aind])
            heapq.heappush(heapb,[mib,bind]) 
        else:
            ans.append([1,aind,bind])
            ans.append([2,aind,bind])
            heapq.heappush(heapa,[-xor,aind])
            heapq.heappush(heapb,[maa,bind])          
                 
print(len(ans))
for row in ans:
    print(*row)
    
0